HttpModule not running with Visual Studio

前端 未结 3 911
一整个雨季
一整个雨季 2020-12-30 00:36

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 sys

相关标签:
3条回答
  • 2020-12-30 00:51

    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.

    0 讨论(0)
  • 2020-12-30 01:11

    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.

    0 讨论(0)
  • 2020-12-30 01:14

    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

    0 讨论(0)
提交回复
热议问题