即使在IIS的web.config中使用<remove>标记后,也会出现重复的部分错误

Leg*_*ion 14 asp.net iis

我有一个站点在另一个站点的子目录中运行.它们在不同的应用程序池中运行 这两个站点正在运行不同版本的Entity Framework.所以在子目录中的web.config中我有:

<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
Run Code Online (Sandbox Code Playgroud)

但即使使用<remove>标签我仍然会收到此错误:

Section or group name 'entityFramework' is already defined. Updates to this may only occur at the configuration level where it is defined.
Run Code Online (Sandbox Code Playgroud)

我还<location>尽可能在父web.config中放置了标签:

<location path="." inheritInChildApplications="false">
Run Code Online (Sandbox Code Playgroud)

<location>标签周围存在父web.config中的<entityFramework>部分.

我已经enableConfigurationOverride="false"在IIS的applicationHost.config文件中放置了(System32和SysWOW64中的文件).

如何防止子目录中的站点看到父entityFramework标记?

编辑

IIS版本:7.5.7600.16385

从父web.config:

<configSections>
  <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
Run Code Online (Sandbox Code Playgroud)

  <location path="." inheritInChildApplications="false">
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="mssqllocaldb" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
  </location>
Run Code Online (Sandbox Code Playgroud)

从子web.config:

  <configSections>
    <remove name="entityFramework"/>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />    
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
Run Code Online (Sandbox Code Playgroud)

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
Run Code Online (Sandbox Code Playgroud)

编辑2

关于使用<clear/>:这会导致关于缺失部分声明的一系列错误.如果我添加~100行的节声明我得到错误:An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.即使我使用<validation validateIntegratedModeConfiguration="false" />in ,错误仍然存​​在<system.webServer>.

gra*_*imp 0

您说您使用了但在您发布的父 web.config 中,路径=“。” 不见了。您将需要它来阻止继承。