【问题标题】:web.config inheritInChildApplications="false" for configSections?configSections 的 web.config inheritInChildApplications="false"?
【发布时间】:2012-08-01 21:20:56
【问题描述】:

我在 IIS 7 上有一个 .NET 4.0 应用程序,其中包含一个嵌套的 .NET 2.0 应用程序。问题是嵌套的 .NET 2.0 应用程序在 web.config 的 <configSections> 中有 system.web.extensions sectionGroup,而 .NET 4.0 父应用程序 machine.config 也包含这些 sectionGroups。这会导致状态码 500 服务器错误。

从子应用程序 web.config 中注释掉 system.web.extensions sectionGroup 是可行的,但不是我们设置的选项。

如何防止在子应用程序中继承父 web.config?我已经看到 <location path="." inheritInChildApplications="false"> 在以前的 .NET 版本中使用过,但是我应该用什么包裹 location 元素呢?

Intellisense 向我显示“不允许使用 inheritInChildApplications 属性”,我将它放在哪里似乎并不重要。

【问题讨论】:

    标签: c# iis inheritance web-config location


    【解决方案1】:

    我们将所有不想继承的设置包装在一个空的位置元素中:

    <location inheritInChildApplications="false">
    

    Intellisense 抱怨它,但它似乎在生产模式下运行得很好。

    this article 中有一些很好的附加信息。

    【讨论】:

    • 我尝试将位于 @ Windows\Microsoft.NET\Framework\v4.0.30319\Config 的 configSection 包装在 location 元素中,嵌套应用程序仍然返回 500 服务器错误。这是走错地方了吗?我想阻止继承的唯一部分是 configSection。
    • 换句话说,我不认为 部分将处理被包装在 location 元素中。
    • 啊,不幸的是,我认为这行不通(没有意识到您在配置部分遇到问题)。可以修改内部应用的配置吗?
    • 是的,我可以。这让我相信最好的解决方案是在子配置中为该部分使用“”。不幸的是,我在 configSection 上替换 web.config 时遇到了真正的麻烦(这完全是另一个问题)。在不过度扩展这个问题的情况下,我只需要在我的暂存构建期间使用“”部分。它不会嵌套在生产或开发中。
    【解决方案2】:

    这种情况下的解决方案是修改我的测试环境以避免configSection 冲突。这种冲突似乎没有真正的解决方案。见这里:How to stop inheritance of configSections in Web Config

    【讨论】:

      猜你喜欢
      • 2010-12-07
      • 2011-05-01
      • 1970-01-01
      • 2012-10-09
      • 2011-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      相关资源
      最近更新 更多