I am using an HttpModule to do some URL shortening on my site. I am using Visual Studio 2008 and IIS 7, and .Net 3.5.
When the module is specified in the system.webServer element of web.config, and the site is run in IIS, it works fine. The config looks like this:
<system.webServer> <modules> <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" /> </modules>...
My module attaches to the BeginRequest event, everything works. However, I can't get it to run using the built-in VS web server (Cassini). I tried moving the module config to the system.web element in web.config, no luck. I put a breakpoint on it, nothing happens.
Any thoughts on why this would be an issue?
(I also tried the Application_BeginRequest event in global.asax. Still no luck, though I'd prefer to keep everything in web.config anyway.)
Cassini, the development web server provided with IIS uses the IIS6 module syntax, so you must duplicate the module add like so
<system.web> <httpModules> <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" /> </httpModules> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <remove name="MinimizeModule" /> <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" preCondition="managedHandler" /> </modules> </system.webServer>
Note that I've also added a precondition to your IIS7 settings
If you are running on IIS 7, put the module in:
<configuration> <system.webServer> <modules> <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" /> </modules> </system.webServer> </configuration>
If you are running on Cassini (Visual Studio's integrated miniature web-server), put the module in:
<configuration> <system.web> <httpModules> <add name="MinimizeModule" type="ClipperHouse.UrlMinimizer.MinimizeModule" /> </system.web> </configuration>
IIS will crash if you give it the Cassini location.
Cassini will crash if you give it the IIS location.
Whenever i deploy, i have to be sure not to deploy web.config
. i also include the notes in web.config
:
<system.web> <!--The Cassini location to add modules (comment out for IIS)--> <httpModules> <!--WARNING: IIS will crash if you leave this in here. IISBUG: IIS doesn't support system.web/httpModules, and Cassini doesn't support system.webServer/modules --> <!--Comment out for IIS--> <add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/> </httpModules> </system.web> <system.webServer> <!--The IIS7 location to add modules (comment out for Cassini) <modules runAllManagedModulesForAllRequests="true"> <!--IIS7 will crash if you present a system.web httpModules. --> <remove name="PerformanceHttpModule" /> <add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/> </modules> </system.webServer>
IIS's left hand doesn't know what Cassini's right hand is doing - and they both screwed it up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With