If you’re new to IIS 7 (you probably are) you might receive this nice little gem when you first start working with it:
HTTP Error 500.19 – Internal Server Error
Description: The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code: 0x80070021
Notification: BeginRequest
Module: IIS Web Core
Requested URL: http://localhost:80/ExampleApplication/
Physical Path: C:\inetpub\wwwroot\ExampleApplication\
Logon User: Not yet determined
Logon Method: Not yet determined
Handler: Not yet determined
Config Error: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.
FONT color=#a52a2a>
Config File: \\?\C:\inetpub\wwwroot\ExampleApplication\web.config
Config Source:
184: </modules>
185: <handlers>
186: <remove name="WebServiceHandlerFactory-Integrated"/>
184: </modules>
185: <handlers>
186: <remove name="WebServiceHandlerFactory-Integrated"/>
IIS 7 implements “Configuration Locking“. This is to help with IIS administration. The IIS Administrator can lock down Configuration Sections, Section Elements and Attributes at the IIS level. This allows the administrator to have a more granular level of control on the system. Read this link to see more about it.
Important Note: In order make these changes, you must be an administrator on the machine where the config file resides. If its on your local machine, you must be an administrator on your machine.
Since I’m on my own development machine, and since this is a development machine, I have decided to change the global setting (the config section itselft). To fix this error I had to go to the applicaitonHost.config file and set the overrideModeDefault to “Allow”.
Here’s how:
Open the applicationHost.config file, located here: %windir%\system32\inetsrv\config\applicationHost.config
In my instance, I need to edit the “handlers” section.
Change this line:
<section name=”handlers” overrideModeDefault=”Deny” />
To:
<section name=”handlers” overrideModeDefault=”Allow” />
Thats it. ๐
You might receive more errors after you enable this, such as the same error for modules, but just follow the same steps above, and you should be good.
Note: You can accomplish this same thing through the command line by using the appcmd.exe application (%windir%\system32\inetsrv\appcmd.exe). Like this:
%windir%\system32\inetsrv\appcmd unlock config -section:system.webServer/handlers
One more note…
This is not something you’d want to do on a production server unless you’re sure you want to enable all appliations to override the section contents. Be sure to read up on some of the docs (explanation of the configuration system) before you make this change on production.
Rakesh Chaubey says
To solve the problem, download the Microsoft Web Platform Installer then fire it up by clicking the downloaded EXE file.
Then make sure that the following options are added and installed:
Products > Server > IIS: Recommended Configuration
Products > Server > IIS: ASP.NET
Products > Frameworks > .NET 3.5 for Windows 8
Products > Frameworks > .NET 4.5 for Windows 8
Now press the Options link and where it says, Which Web Server would you like to use? ensure the IIS is selected and not IIS Express (more info here).
Also check down through all the various options to ensure that anything else that you might use (e.g. IIS Directory browsing etc).
Hit the Install button and the Platform Installer will work its magic and set up all the configuration files automatically.
The pages should now run okay within IIS 8.
Jim Jef says
Great post Donn.
For those who want to solve the problem by changing this configuration in a single site of their server, just put the tag inside a tag in the same file mentioned in this post.
Ex:
it is possible to add many other configurations in this block, but here I highlighted only the one that refers to the error mentioned in this post.