Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Steps to Investigate Cause of Web.Config Duplicate Section

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?
like image 911
Pauly Avatar asked Mar 19 '10 06:03

Pauly


People also ask

What are the different sections in a web config file?

A . config file contains XML that has a configuration element as the root node. Information inside this element is grouped into two main areas: the configuration section-handler declaration area, and the configuration section settings area.

Can we have 2 web config?

Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.


2 Answers

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.

like image 126
Pauly Avatar answered Sep 22 '22 19:09

Pauly


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.

like image 38
Pure.Krome Avatar answered Sep 19 '22 19:09

Pure.Krome