gpt4 book ai didi

asp.net - 禁用 web.config 继承?

转载 作者:行者123 更新时间:2023-12-02 04:46:03 25 4
gpt4 key购买 nike

我的网站根目录中有一个内容管理应用程序,我正在尝试在子文件夹下使用另一个应用程序(计费应用程序)。不幸的是,根站点的 web.config 干扰了子应用程序。

有没有办法只禁用子文件夹的 web.config 继承?

更新:Stephen Burris 链接,使用<location>标签可以阻止部分Web配置的继承,如下:

<?xml version="1.0"?>
<configuration>
<configSections>
....
</configSections>
<location path="." inheritInChildApplications="false">
<appSettings>
....
</appSettings>
<connectionStrings/>
<system.web>
....
</system.web>
<system.codedom>
....
</system.codedom>
<system.webServer>
....
</system.webServer>
</location>
<runtime>
....
</runtime>
</configuration>

<configSections><runtime>部分不会接受包含在标签中...所以我想这只能完成大部分工作。有人知道如何做得更好吗?

最佳答案

您可以在根 web.config 文件中使用一个属性,以使其内容不被子应用程序继承。

继承InChildApplications

Blog about inheritInChildApplications

MSDN article on ASP.NET Configuration File Hierarcy and Inheritance

将配置中不用于继承的部分放在里面

<location inheritInChildApplications="false">
<NotInheritedConfigPart/>
</location>

配置部分似乎不可能不继承,但配置的其他部分可以像这样“注释”掉并且不被继承。

关于asp.net - 禁用 web.config 继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/367282/

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