Steps to Investigate Cause of Web.Config Duplicate Section

asp.net, asp.net-mvc, iis-7

Solution

Add this to the checklist.

- Make sure that the machine.config you check is from the same Dot Net framework as the application pool your application is running under.

In my case the default application pools was changed from Dot Net 2.0 to Dot Net 4.0. This changed the root machine.config to the 4.0 version. This version contains the "scriptResourceHandler" section as well as others. Thus the duplicate section warning.

Problem

Symptoms - In IIS 7 and Dot Net 2.0 Integrated app pool: double clicking to view any web.config section results in an error dialog like this: Browsing to the URL displays: "Http 500.19" internal server error.. There is a duplicate... 'system.web.extensions/scripting/scriptResourceHandler' section defined...." Running the app from VS 2008 an "Unable to start debugging on the web server..." dialog is displayed. Infrastructure - Web server: IIS 7 running on Windows 7 x64 - ASP.Net MVC2 - Application pool: Dot Net 2.0 integrated - VS 2008 Things Tried - Checked to see if the problem was occurring in other IIS app directories on the same machine. - Removed and re-added the application in IIS. - Reverted to prior versions of the web.config file. - Checked out a last working version of the source code. Rebuilt the app, added a new app directory for it and tried to view web.config contents from IIS. - Looked for web.config files that might have duplicate sections in: - Inetpub root. - "C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config" - The "Views" subfolder of the ASP.Net MVC app. - Checked out source code to another dev machine. Setup IIS 7 app folder. No problem with Web.config. Question - If the reason for this error is another web.config file where else should I look? - Are there other reasons for these symptoms?

Original source