IIS 7 抛出“重复的节定义”错误一台服务器上的 web.config 错误,但另一台服务器上没有错误
我有 3 台服务器,所有服务器都运行 Windows Web Server、.NET 4 和 IIS7。我的 web.config 文件的开头部分是:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
这在 2 台服务器上工作正常,但其中一台报告错误:
定义了重复的“system.web.extensions/scripting/scriptResourceHandler”部分
:
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
如果我删除该行,那么它会抱怨下一行的重复,依此类推,直到我删除几乎所有配置部分。
知道什么会导致这种情况吗?
编辑:
这是一个 .NET 3.5 应用程序,已更新到 VS 2010 和 .NET 4。所有 3 台服务器都安装了 .NET 2/3.5 和 4。 IIS 应用程序池已全部更新到 .NET 4。
在所有 3 个服务器中,machine.config
文件中已经定义了其中一些 web.config 部分(正如 Damien 的回答提到的那样),但是3 个中只有 1 个抱怨它被重复。
I have 3 servers, all of which are running Windows Web Server, .NET 4, and IIS7. The beginning section of my web.config file is:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
This works fine on 2 of the servers, but one of them reports the error:
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
against the line:
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
If I remove that single line, then it complains about a duplicate of the next line, and so on until I remove almost all of the config sections.
Any idea what would cause this?
Edit:
This was a .NET 3.5 application that was updated to VS 2010 and .NET 4. All 3 servers have .NET 2/3.5 and 4 installed. The IIS app pools have all been updated to .NET 4.
In all 3 servers, the machine.config
file already has some of these web.config sections defined in it (as Damien's answer mentions), but only 1 of the 3 complains about it being duplicated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在“损坏的”服务器上,您的应用程序池正在运行 .NET 4.0。修复方法是将应用程序池设置为以 .NET 2.0 运行。
由于 ASP.NET AJAX 是在 .NET 2.0 之后发明的,因此配置定义从未进入中央 web.config,因此在大多数情况下您必须在每个站点的基础上声明它们。 4.0 清理了很多这样的问题,但其副作用是破坏了 ASP.NET 早期版本的默认配置。
On the "broken" server your app pool is running .NET 4.0. The fix is to set the app pool to run as .NET 2.0.
Because ASP.NET AJAX was invented after .NET 2.0, the configuration definitions never made it into the central web.config so you had to declare them on a per-site basis in most circumstances. 4.0 cleaned up lots of that cruft, with the side effect of breaking the default configurations for preceding versions of ASP.NET.
检查了我机器上的
machine.config
后,似乎已经定义了这些部分。它们是否已从其他计算机的machine.config
中删除(或者该站点实际上是在这些其他服务器上的早期版本的 ASP.Net 下运行?)据我所知,这些部分是由
machine.config
中默认安装的 ASP.NET 4 定义的。Having checked the
machine.config
on my machine, it seems to have these sections defined already. Have they been removed from the other machines'machine.config
(Or was the site, in fact, running under an earlier version of ASP.Net on these other servers?)So far as I can see, these sections are defined by a default install of ASP.NET 4 within
machine.config
.我遇到了有关重复部分的类似错误,并将其修复为部署到 IIS 上的其他网站。
我在该网站上部署了大量旧应用程序,我认为与 web.config 存在一些冲突。
我刚刚删除了该网站,创建了一个新网站并部署在那里,它就工作了。
I was getting a similar error about duplicated sections and fixed it deploying to a different website on IIS.
I had tons of old applications deployed on that website and I think there were some conflict with the web.config.
I just deleted the website, create a new one and deploy there and it worked.