Thursday, April 24, 2008

Using HttpModules and HttpHandlers under IIS7

IIS 7 uses by default a new Integrated type of Application Pool. Old style Pool called Classic is available as well. As I discover after some trouble, to use HttpModules and HttpHandlers in ASP.NET application running under Integrated Application Pool, one need to add additional lines to Web.config file.
Normally, you put HttpHandlers and HttpModules sections inside system.web section.
To work under Integrated Application Pool, Web.config should put modules and handlers sections inside system.webServer section:

<configuration>
<!-- This is for Classic Application Pool -->
<system.web>
<httpModules>
<add name="IntranetPageHttpModule" type="CoTs.Intranet.IntranetPageHttpModule" />
</httpModules>
<httpHandlers>
</httpHandlers>
</system.web>
<!-- This is for Integrated Application Pool -->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="IntranetPageHttpModule" type="CoTs.Intranet.IntranetPageHttpModule" />
</modules>
<handlers>
</handlers>
</system.webServer>
</configuration>







References:


ASP.NET Integration with IIS7 by Mike Volodarsky, page2.


HttpModule and HttpHandler sections in IIS 7 web.config files - Rick Strahl's Web Log