App.config issues - configuration

When i modified my app.config to include the ReflectSoftware logging infomration, Ninjatrader crashed. Can you point out where I did not configure it correctly?
?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>
<configSections>
<section name="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
In order to recieve location information, you must ensure the layout has the parameter ${callsite} and all
its properties set accordantly.
-->
<extensions>
<add assembly="ReflectSoftware.Insight.Extensions.NLog"/>
</extensions>
<targets>
<target name="ReflectInsight"
xsi:type="ReflectInsight"
instanceName="nlogInstance1"
displayLevel="true"
displayLocation="true"
layout="${callsite:className=true:fileName=true:includeSourcePath=true:methodName=true}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="ReflectInsight" />
</rules>
</nlog>
</configuration>

fixed by moving the xml fragment after Config sections

Related

Angular universal web config file with ssl and www redirecting

I have a little problem with the web.config file of my angular universal project. My web.config file is like this;
<configuration>
<system.webServer>
<!-- indicates that the server.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="main.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="sendToNode">
<match url="/*" />
<action type="Rewrite" url="main.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
We are trying to add a www redirecting when there is no www written into link and a https redirecting when there is no https written in the url. But we couldnt manage to do this.
Should I need to do something from the Angular for this?
How can we add those two redirectings into our angular universal web config?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000"/>
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-Frame-Options" value="DENY" />
<add name="X-XSS-Protection" value="1; mode=block" />
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the main.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="main.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
</rule>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^main.js\/debug[\/]?" />
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<match url="^(?!.*login).*$"></match>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
</conditions>
<action type="Rewrite" url="main.js"/>
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
</outboundRules>
</rewrite>
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!-- Restart the server if any of these files change -->
<iisnode watchedFiles="web.config;*.js;browser/*.*" />
</system.webServer>
</configuration>

ServiceStack 4 Razor: no intellisense in Visual Studio 2013 with update 2

I am running a Asp.Net Host (ServiceStack.Host.AspNet 4.0.30.0) - ServiceStack 4.0.30.0 project with Razor.
.Net Framework Target: 4.5.1
The project compiles fine, but I am not getting any intellisense in my Razor Views using Visual Studio 2013 with Update 2.
Any ideas on how to get intellisense to work in the ServiceStack Razor views?
My machine has MVC 4 and 5 installed as well.
Here is also a copy of my web.config...
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
</configSections>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.1" />
</system.Web>
-->
<system.web>
<httpRuntime />
<compilation targetFramework="4.5.1" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders></compilation>
<pages controlRenderingCompatibilityVersion="4.0" />
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers></system.web>
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="windows_consumer81_demo.Models" />
<add namespace="windows_consumer81_demo.Models.Scenario" />
<add namespace="windows_consumer81_demo.Localization" />
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="windows_consumer81_demo" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
</system.web.webPages.razor>
<appSettings>
<add key="DebugMode" value="true" />
<add key="unsupportedRedirect" value="unsupported.html" />
<add key="vs:EnableBrowserLink" value="false" />
<add key="webPages:Enabled" value="false" /></appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</configuration>
I guess the way it's supposed to work is that all the namespaces you add in web.config should have IntelliSense:
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="YourNameSpaceHere" />
<add namespace="SomeServiceStackNameSpace" />
. . .
Then in the .cshtml file you'd add:
#inherits ViewPage<YourModelClassName>
Unfortunately this doesn't always work. It compiles, but you don't get IntelliSense.
However there is a fix:
In your .cshtml file just type out the full namespace:
#inherits ServiceStack.Razor.ViewPage<Full.Namespace.Of.Your.Model.Class>
If you're using other classes, just add:
#using MyServer.ServiceInterface;
#using MyServer.ServiceModel;
Another trick I recommend is to strongly type your #Model object. Right there at the top, after the #Inherits ViewPage<...> stuff add:
#{
Your.Class.Name TypedModel = Model;
}
Feel free to rename TypedModel to something better.

I want to redirect nitroindia.org to www.nitroindia.org in godaddy windows hosting [duplicate]

This question already has answers here:
asp.net MVC: How to redirect a non www to www and vice versa
(9 answers)
Closed 6 years ago.
I wanted to redirect my website nitroindia.org to www.nitroindia.org in windows hosting w.ith web.config file. I replaced the web.config file but It gave me a resultant 500 Internal Server error.
<?xml version=�1.0? encoding=�utf-8? ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=�Redirect for ML2? stopProcessing=�true�>
<match url=�.*� />
<conditions>
<add input=�{HTTP_HOST}� pattern=�^nitroindia.org$� />
</conditions>
<action type=�Redirect� url=�http://www.nitroindia.org/{R:0}� redirectType=�Permanent� />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
My default file name is index.html
I'm guessing you are using IIS 7.5 and below should work:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical host name">
<match url="^(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Nlog.Targets.Redis: How to configure NLog for redis target?

Following is a simple nlog configuration containing simple logfile target. My problem is how to add a target for Nlog.Targets.Redis?
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
</targets>
Following is the right configuration for NLog.Targets.Redis. If you get the package with nuget, notice that nuget installs wrong NLog version, so you should put the dependentAssembly section like below.
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<runtime>
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="en-us" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="2.0.1.2" />
</dependentAssembly>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">
<extensions>
<add assembly="NLog.Targets.Redis" />
</extensions>
<targets>
<target name="redis" type="Redis" host="192.168.56.2" key="logstash" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="redis" />
</rules>
</nlog>
</configuration>

Under Spring Framework: WARN: WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)

I have spent all day trying to solve the logging problem I'm having with log4j in a webapp. No matter what I do, I cannot get rid of the following:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Just to be clear, I have read all of the articles here on Stack Overflow addressing this issue. I've read the log4j manual. I've been through a dozen different tutorials. I've tried the properties approach and the XML approach (log4j.properties and log4j.xml, respectively). Also, I have confirmed that the log4j.xml file is being read. Aside from the fact that the server tells me so during startup, I can influence the level of feedback through the .xml file. So, yes, the log4j.xml file is in the CLASSPATH.
I know I'm missing something simple and fundamental. Below are the relevant files:
LOG4J.XML (/WEB-INF):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<!-- Application Loggers -->
<logger name="com.tiersoftinc.testlog">
<level value="info" />
</logger>
<!-- 3rdparty Loggers -->
<logger name="org.springframework.core">
<level value="info" />
</logger>
<logger name="org.springframework.beans">
<level value="info" />
</logger>
<logger name="org.springframework.context">
<level value="info" />
</logger>
<logger name="org.springframework.web">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
and WEB.XML (/WEB-INF):
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters, and the applicationContext.xml file -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
/WEB-INF/spring/app-context.xml
</param-value>
</context-param>
<!-- Logging listener -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
and APP-CONTEXT.XML (/WEB-INF/spring):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config />
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
For example #Controller and #Service. Make sure to set the correct base-package -->
<context:component-scan base-package="com.tiersoftinc.gridlab3" />
<!-- Configures the annotation-driven Spring MVC Controller programming model.
Note that, with Spring 3.0, this tag works in Servlet MVC only! -->
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- Imports datasource configuration -->
<import resource="app-context-mongo.xml"/>
</beans>
and APP-CONTEXT-MONGO.XML (/WEB-INF/spring):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<!-- Activate Spring Data MongoDB repository support -->
<mongo:repositories base-package="com.tiersoftinc.gridlab3.repository" />
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/spring/database.properties</value>
</list>
</property>
</bean>
<!-- MongoDB host -->
<mongo:mongo host="${mongo.host.name}" port="${mongo.host.port}"/>
<!-- Template for performing MongoDB operations -->
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"
c:mongo-ref="mongo" c:databaseName="${mongo.db.name}"/>
<!-- Service for initializing MongoDB with sample data using MongoTemplate -->
<bean id="initGridLab3Service" class="com.tiersoftinc.gridlab3.services.InitGridLab3Service" init-method="init"/>
</beans>
and, finally, ROOT-CONTEXT.XML (/WEB-INF/spring):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<context:annotation-config />
</beans>
What am I missing?
Thank you.
Have you tried this?
<logger name="org.springframework.web">
<level value="info" />
<appender-ref ref="console" />
</logger>
Put these lines in the beginning of your web.xml:
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/main/resources/log4j.xml</param-value>
</context-param>