Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 development web server does not use integrated-mode HTTP handlers/modules

I am developing an ASP.NET MVC 2 web site, targeted for .NET Framework 4.0, using Visual Studio 2010.

My web.config contains the following code:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="XhtmlModule" type="DomenicDenicola.Website.XhtmlModule" />
    </modules>
    <handlers>
        <add name="DotLess" type="dotless.Core.LessCssHttpHandler,dotless.Core" path="*.less" verb="*" />
    </handlers>
</system.webServer>

When I use Build > Publish to put the web site on my local IIS7 instance, it works great.

However, when I use Debug > Start Debugging, neither the HTTP handler nor module are executed on any requests.

Strangely enough, when I put the handler and module <add /> tags back into <system.web /> under <httpHandlers /> and <httpModules />, they work. This seems to imply that the development web server is running in classic mode.

How do I fix this?

like image 734
Domenic Avatar asked Apr 25 '10 12:04

Domenic


3 Answers

You don't. WebDev.WebServer.exe does not and cannot support integrated pipeline.

So, if you have code that cannot be written to perform in both environments you will need to use a local IIS for development.

Basically, system.web is the place to configure webdev server and IIS5-6 handlers and modules. system.webServer is for IIS7 handlers and modules, as you know.

Reference:

Each request in WebDev.WebHost40 (and previous versions) is processed by HttpRuntime.ProcessRequest (which does not support integrated pipeline mode). This is the method used in all three versions of WebHost.WebServer.dll (the core of WebDev.WebServer.exe)

And the word of some dude who is fairly familiar with the inner workings of Cassini/WebDev by virtue of managing this project. ;-)

like image 122
Sky Sanders Avatar answered Oct 19 '22 00:10

Sky Sanders


I'm not sure if I'm too late in answering, but while it's known fact that the Cassini server doesn't support integrated pipeline mode, you can still test locally using the classic pipeline by adding it to the httpModules section of system.web in your web.config:

  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    .
    .
    .
    <!-- HTTP Modules using Classic Pipeline -->
    <httpModules>
      <add name="YourHttpModule" type="ACME.YourHttpModule"/>
    </httpModules>
  </system.web>

  <system.webServer>
    <!-- HTTP Modules using Integrated Pipeline -->
    <modules runAllManagedModulesForAllRequests="true">
      <add name="YourHttpModule" type="ACME.YourHttpModule"/>
    </modules>
  </system.webServer>

You'd probably want to remove the httpModules section from your production web.config.

like image 4
Bullines Avatar answered Oct 18 '22 22:10

Bullines


Got this today while running in visual studio 2012. Found the reason was visual studio launched the old web server that comes with 2010 and as explained above it can't work there. Changed to IIS Express by right click on properties, choose "Web" tab and and selecting IIS Express option. Then launching debug mode will start in IIS Express and this aparently supports operations such as Request.Headers.Add or whatever caused your exception.

like image 4
John Avatar answered Oct 18 '22 22:10

John