开发者

Steps to Investigate Cause of Web.Config Duplicate Section

开发者 https://www.devze.com 2022-12-23 04:48 出处:网络
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:

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:

Steps to Investigate Cause of Web.Config Duplicate Section

  • 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:
    • I开发者_如何学JAVAnetpub 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?


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.


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.


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.


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 :)


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


My issue was quite different and this will depend on what section is a duplicate.

For instance I had a duplicate loggingConfiguration section which appear to be the result of the parent and child app using different versions of Microsoft Enterprise Library


It might be worth opening up the applicationHost.config file:

C:\Windows\System32\inetsrv\config\applicationHost.config

Specifically, look for <location> tags that match the site name (there can be multiple entries) and see if there's duplicate scriptResourceHandler sections declared there. I'd also check the contents of <location path=""> as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号