HttpModule and HttpHandler sections in IIS 7 web.config files
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.
The Voices of Reason
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
I'll definitely be using this switch in just about any demo app <g>...
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
lets see if you can help out with this one...
I have a custom control that has a designer that updates the web.config of the host web application. It registers a custom http handler that is part of the custom control assembly.
(see http://www.tkachenko.com/blog/archives/000686.html for more information)
Now, this worked perfectly until IIS7. I can't seem to be able to get ahold of the system.webServer section to add a handler in design time. Any thoughts??
Thanks
Stefan
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
I created HttpModule. When I try and register it under <system.webServer>, I dont get <modules> section listed in the intellisence.
I want to invoke that module for paths like (*) -
http://mysite/mihir (will redirect to - http://mysite/employee.aspx?name=mihir)
Am I doing anything wrong?
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
Thanks,
Matt
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
Andy
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
Before going for actual setting I would like to suggest please go through the following link foum on one forum for more detail
http://www.infosysblogs.com/microsoft/2007/02/configuring_custom_http_handle.html
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
I've come across your site a couple of time over the last months and read some usefull info. Therefore, I would like to mention to you a little thing (or even a bug) I've seen...
I wanted to share sessions between webapps on the same server / URL / domain, with IIS7. I found a solution on codeplex http://www.codeproject.com/KB/session/sharedsession.aspx ... it worked perfectly on cavini, but when on local IIS7 webapps (everything the same), it refused.
Seems that IIS7 refuses <system.web><httpModules> implementations, while modules declared in <system.webServer><modules> are processed.
To prove yourself, just download the above session-tweak allowing to share sessions between different apps on the same server (SQL State enabled) - do the above - Cavini works, IIS7 doesn't. Then, just copy-cut the module to the new IIS7-section and it works again.
I think the ELMAH works again too...
And it is a way to avoid having to spend loads of money on 3rd party Cache / Sessionstate software - for the time-being...
Have fun at Hawaii!
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
Finally came down to taking out the httpmodules from under system.web.
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
ERROR ( message:Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to '*_AppService.axd_*'
Any ideas?
# re: HttpModule and HttpHandler sections in IIS 7 web.config files
When we made the Integrated pipeline the default for ASP.NET applications on Windows Vista and beyond, making sure that apps continue to work correctly was our biggest concern.
Having the modules and handlers listed in the new IIS configuration was a major potential breaker, I wanted to be very very clear about it and make sure people couldnt just let a legacy app run in Integrated mode and be missing its modules or handlers. Hence the detailed error message, and the built-in migration support in AppCmd.
The Vista error message is even better then Windows Server 2008, since it actually gives you the exact command to migrate (copy paste baby!). On server, the message had to be changed and just gives an example, but by this point people should already be more comfortable with the whole thing.
There is a little bit more background in the ASP.NET Integration article: http://www.iis.net/default.aspx?i=928&subtabid=25&tabid=2&p=2.
Thanks,
Mike