views:

494

answers:

2

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.)

A: 

Did you try also putting the module declaration in the element? When running in dev using Cassini, that's usually the place I have to put modules to get them running.

Mark Struzinski
Could you expand on this further? I'm not sure what you mean.
mgroves
+7  A: 

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

blowdart
this looks promising, will get back to you soon with results...
Matt Sherman
tried this. My module .ctors and Init()s but any attempt to attach event handlers is met with PlatformNotSupportedException - Cassini seems to totally ignore the IIS7 section.
Hafthor
Well yes, Cassini does - you have to add the IIS6 syntax too, hence having both there
blowdart