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:

<!-- This is for Classic Application Pool -->
<add name="IntranetPageHttpModule" type="CoTs.Intranet.IntranetPageHttpModule" />
<!-- This is for Integrated Application Pool -->
<validation validateIntegratedModeConfiguration="false" />
<add name="IntranetPageHttpModule" type="CoTs.Intranet.IntranetPageHttpModule" />


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

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