i have a simple IHttpModule
:
using System;
using System.Web;
namespace DummyPlaceholder
{
class PerformanceHttpModule : IHttpModule
{
public void Init(HttpApplication application)
{
}
public void Dispose()
{
}
}
}
And you register HttpModules inside web.config
:
<configuration>
<system.web>
<httpModules>
<add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
</httpModules>
</system.web>
</configuration>
When i was developing, and testing locally inside my Visual Studio 2012 integrated ("Cassini") web-server, everything worked great.
When it came time to deploy to a live IIS7 web-server, the server would give a 500 Internal Server Error, and absolutely no information about the cause anywhere.
The issue is that IIS7 changed how you register HttpModules, you no longer use system.web
, instead you must now use system.webServer
:
<configuration>
<system.webServer>
<modules>
<add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
</modules>
</system.webServer>
</configuration>
And now that works on IIS, but doesn't work inside Visual Studio 2012.
What i need is a solution that works in both, without having to modify the web.config
file when it is being published.
The issue is that IIS7 and newer, have a new "Integrated" mode. The alternative mode is the behavior that IIS6 had, called "Classic" mode.
Obviously i need to put the Visual Studio integrated web-server into "Integrated" mode, so that it look at:
configuration/webServer/modules
for modules.
How do i do that?
Here's a guy from the Cassini project explaining that "Integrated" modules will never be supported.
And among the dozen or so questions of people suffering with this problem, there was a hack solution:
You issue a remove
to remove the system.web/httpModule
, before you add the system.webServer/module
module.
<configuration>
<system.web>
<httpModules>
<add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
</httpModules>
</system.web>
<system.webServer>
<modules>
<remove name="PerformanceHttpModule" />
<add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/>
</modules>
</system.webServer>
</configuration>