gpt4 book ai didi

asp.net - 如何停止 Web.Config 中 的继承

转载 作者:行者123 更新时间:2023-12-03 07:21:10 24 4
gpt4 key购买 nike

您根本无法使用<location path="." inheritInChildApplications="false">在 web.config 的某些部分,以便告诉它忽略某些部分的继承(您会收到诸如“未声明 inheritInChildApplications 属性”之类的错误,如果您尝试将其放入不支持的部分,则会出现第四个错误)。

例如,您不能在 <configSections> 之前或内部使用它。例如,您可以包装您的 <system.web>位置标签中的标签,但我需要停止 <configSections> 中任何内容的继承我看不出有什么办法可以做到这一点。

我的子应用程序继承了树中 IIS 7 中父应用程序 Web 配置的一些相同配置设置。我看不出有什么办法可以写 <clear/>要么在 configSecion 标记中,因为如果您尝试将其添加到那里,它是无效标记。

你如何告诉它忽略该部分?

最佳答案

这个同样的问题在 SO 以及许多其他论坛上被多次问到,答案或多或少是相同的,不,你不能使用 location/clear/remove 来配置部分。

微软甚至在他们的帖子中回复如下。

Posted by Microsoft on 7/23/2009 at 5:40 PM

 <clear /> and <remove />

were never implemented for configSections and sectionGroups because of the difficulty involved attempting to merge different definitions of the same section-handlers and section groups.

We considered adding this type of functionality for the VS 2010 release, but we decided against it for two reasons.

The first one being the additional complexity it brings, in large part because section handlers and section groups are used to bootstrap the configuration system. As a result allowing for merge semantics in the middle of bootstrapping the configuration system is a non-trivial problem to solve.

The second reason is that usually section handlers and section group definitions are made in two distinct places - an initial set of registrations up in the root configuration files, and then an additive set of registrations in application level web.config. That doesn't mean a scenario where a developer wants to modify handler definitions isn't valid - its just a low likelihood scenario. Thank you for taking the time though to submit your suggestion via Connect!

<小时/>

查看这个 SO 线程,其中简单的状态避免使用冲突的节组。

但是,Nairman 建议遵循以下步骤:

I'm not sure that you can have the same section defined differently in a sub-folder; you could make that sub-folder a stand-alone virtual application, in which case it wouldn't inherit any of the settings from the parent; in this scenario, it would also execute in its own app pool; if you don't have InProc dependencies, that's an option as well

How to prevent inheritance for web.config file for "configSections"?

关于asp.net - 如何停止 Web.Config 中 <configSections> 的继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1572326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com