Steps to Investigate Cause of Web.Config Duplicate Section

29,954

Solution 1

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.

Solution 2

If you're using DotNetOpenAuth library in your website AND your website is a .NET 4.0 app, then you need to make sure this line is NOT in your web.config

<section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

I installed DNOA using NuGet, and it automatically added that line into my web.config file. So I had to remove it.

BTW people, if you using the built in (hella-crappy) visual studio development server (aka Cassini) .. you will not get this problem/issue. It's only when u move your code over to IIS7 express or full IIS7 will this issue occur.

So delete that single line and then have a happy dance.

Solution 3

In IIS 7 change the Application Pools setting for the appPool named "Classic .NET AppPool" to V2.0. Do this by right clicking the Classic .NET AppPool and selecting "Basic Settings..." then reset the .NET Framework Version to V2.0.xxxxx. Recycle the app pool and restart the web site and it should work fine.

Solution 4

The solution is to change your machine.config.

  1. Move the sections to the machine.config for ASP.NET 2.0
  2. Or Remove the sections from the machine.config for ASP.NET 4.0

Here the people from www.asp.net give a posible fix: http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes

Take a look :)

Solution 5

This MS troubleshooting might help also: http://support.microsoft.com/kb/942055

Share:
29,954
Pauly
Author by

Pauly

Software developer with experience in full stack web based line of business applications. Current focus on front end web development, and micro services.

Updated on July 09, 2020

Comments

  • Pauly
    Pauly almost 4 years

    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:

    "There was an error while performing this operation....   Filename... web.config...    Error: There is a duplicate..."

    • 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?
  • graffic
    graffic over 13 years
    This seems the case. While this doesn't solve the problem it's a good start.
  • Philippe
    Philippe over 12 years
    In fact, when using the IIS Manager's configuration editor feature, you can choose any standard configuration setting and see where it's set from (deepest path). You can also check the settings for any of the config files in the hierarchy by changing the "from" drop-down location.
  • AndreyMagnificent
    AndreyMagnificent over 12 years
    I did this and ran into another blocker. This answer was the second thing I had to do to get my app working: stackoverflow.com/a/5485155/106639
  • Robin Green
    Robin Green about 10 years
    This is not a very good answer, but I upvoted it because it was nevertheless useful. In my case, the problem was that the .NET version for the application pool being used (not the "Classic .NET AppPool") was the wrong version.