If you have something like the following in your IIS 7 web.config file:

<system.web>
  <httpModules>
     <add name="wwScriptCompressionModule" type="Westwind.Web.Controls.wwScriptCompressionModule,jquerycalendar" />
  </httpModules>
</system.web>
<system.webServer>
    <modules>
      <add name="wwScriptCompressionModule" type="Westwind.Web.Controls.wwScriptCompressionModule,jquerycalendar" />
    </modules>
</system.webServer>

you've probably seen the IIS 7 Exception that lets you know that in Integrated mode in IIS 7 you are not supposed to have an httpModules or httpHandlers section in <system.web>:

Server Error in Application "West Wind Dev/jQueryWeb"


HTTP Error 500.0 - Internal Server Error

Description: This application is running in an application pool that uses the Integrated .NET mode. This is the preferred mode for running ASP.NET applications on the current and future version of IIS.
In this mode, the application should not specify ASP.NET module components in the <system.web>/<httpModules> configuration section. Instead, it should use the <system.webServer>/<modules> configuration section to load ASP.NET module components. You have the following options:

1) Migrate the application to work with the Integrated .NET mode (PREFERRED).
You can migrate the application configuration, including the contents of the <httpModules> configuration section, by using the following from a command line window (the window must be running as Administrator):
%systemroot%\system32\inetsrv\APPCMD.EXE migrate config "West Wind Dev/jQueryWeb"
After you migrate your application, it will run in both Classic and Integrated .NET modes, as well as on downlevel platforms.
2) Move this application to an application pool using the Classic .NET mode.
You can move the application to the default application pool using the Classic .NET mode by running the following from an command line window (the window must be running as Administrator):
%systemroot%\system32\inetsrv\APPCMD.EXE set app "West Wind Dev/jQueryWeb" /applicationPool:"Classic .NET AppPool"
Alternatively, you can use any other application pool on your system that is running in the Classic .NET mode. You can also use the IIS Administration tool to move this application to another application pool.
It is preferred that you migrate this application by using option 1 to take advantage of the benefits provided by the Integrated .NET mode.

Error Code: 0x80070032

Notification: BeginRequest

Module: ConfigurationValidationModule

Requested URL: http://localhost:80/jqueryWeb/jQueryCalendar.aspx

Physical Path: c:\projects2008\articles\jQueryWeb\jQueryCalendar.aspx

Logon User: Not yet determined

Logon Method: Not yet determined

Handler: PageHandlerFactory-Integrated

Most likely causes:

  • IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
  • IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
  • IIS was not able to process configuration for the Web site or application.
  • The authenticated user does not have permission to use this DLL.
  • The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.

What you can try:

  • Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
  • Check the event logs to see if any additional information was logged.
  • Verify the permissions for the DLL.
  • Install the .NET Extensibility feature if the request is mapped to a managed handler.
  • Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.

More Information... This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error.

Microsoft Knowledge Base Articles:

  • 294807

Server Version Information: Internet Information Services 7.0.

If nothing else you gotta give it to IIS 7 - the error messages it fires are very descriptive and point right at the problem.

Anyway if you see this error you're running IIS 7 in integrated mode and you have an <httpHandler> or <httpModule> definition set up in your <system.web> section of your web.config file. It doesn't matter if you have a <module> or <handlers> section set up in <system.webserver> (which is the IIS 7 server configuration section). Unless you remove the system.web handlers and modules the above error occurs.

This can be annoying if you're moving between two machines that run IIS 5/6 and IIS 7. For example, I do all of my dev on Vista with IIS 7 but my Web Server runs IIS 6 on Windows 2003. It's also problematic if you send sample code out that 'should just run'.

After a discussion earlier today I was pointed at a switch by Ryan Trudelle-Schwarz which allows you to have modules and handlers defined in both places so your code won't break under IIS 7:

<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
    <add name="wwScriptCompressionModule" 
         type="Westwind.Web.Controls.wwScriptCompressionModule,jquerycalendar" />
  </modules>
</system.webServer>

With this flag in place IIS 7 won't validate httpModules and httpHandlers in system.web and won't throw the exception page that you need to migrate your handlers. And thankfully this flag works at the web.config level!

The configurability on IIS 7 comes through again.