I am getting error when I launch my application.
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
I have created an HTTP module which read information from the request header and writes data into cookies. Here is the code.
namespace My.Web
{
public class UserIdModule : IHttpModule
{
private HttpApplication httpApp;
public void Init(HttpApplication application)
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
}
private void Application_BeginRequest(Object source, EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
//Read header
string userId = context.Request.Headers["user_id"];
if (string.IsNullOrEmpty(userId))
{
userId = "guest";
}
//Create and write cookie
HttpCookie userCookie = new HttpCookie("userId", userId);
userCookie.Expires = DateTime.Now.AddYears(5);
context.Response.Cookies.Add(userCookie);
}
public void Dispose() { }
}
}
In my web.config
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
</staticContent>
<!-- To register the module for IIS 6.0 and IIS 7.0 running in Classic mode -->
<modules>
<add name="UserIdModule" type="UserIdModule"/>
</modules>
</system.webServer>
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<!-- To register the module for IIS 7.0 running in Integrated mode -->
<httpModules>
<add name="UserIdModule" type="UserIdModule"/>
</httpModules>
</system.web>
</configuration>
This is the screenshot of the error: