我正在尝试添加
<location inheritInChildApplications="false">
到我的父web应用程序的web.config,但它似乎不起作用。
我父母的web.config
有:
<configuration>
<configSections>
</configSections>
// 10 or so custom config sections like log4net, hibernate,
<connectionStrings>
</connectionStrings>
<appSettings>
</appSettings>
<system.diagnostics>
</system.diagnostics>
<system.web>
<webParts>
</webParts>
<membership>
</membership>
<compilation>
</compilation>
</system.web>
<location ..>
<system.web>
</system.web>
</location>
<system.webServer>
</system.webServer>
我的子web应用程序被设置为IIS中的应用程序,并且继承自导致问题的父级web.config
。
我到底应该把
<location inheritInChildApplications="false">
所以它会忽略所有的web.config设置?
发布于 2011-05-12 02:10:04
作为前面提到的答案的评论者,您不能简单地添加行...
<location path="." inheritInChildApplications="false">
<configuration>
下面的...just。相反,您需要包装要禁用继承的单个web.config节。例如:
<!-- disable inheritance for the connectionStrings section -->
<location path="." inheritInChildApplications="false">
<connectionStrings>
</connectionStrings>
</location>
<!-- leave inheritance enabled for appSettings -->
<appSettings>
</appSettings>
<!-- disable inheritance for the system.web section -->
<location path="." inheritInChildApplications="false">
<system.web>
<webParts>
</webParts>
<membership>
</membership>
<compilation>
</compilation>
</system.web>
</location>
虽然<clear />
可能适用于某些配置部分,但有些配置部分需要<remove name="...">
指令,还有一些似乎也不支持。在这些情况下,设置inheritInChildApplications="false"
可能是合适的。
发布于 2009-04-23 15:30:02
它需要直接转到根<configuration>
节点下,您需要设置如下路径:
<?xml version="1.0"?>
<configuration>
<location path="." inheritInChildApplications="false">
<!-- Stuff that shouldn't be inherited goes in here -->
</location>
</configuration>
处理配置继承的更好方法是在您不想继承的地方使用子配置中的<clear/>
。因此,如果你不想继承父配置的连接字符串,你可以这样做:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<clear/>
<!-- Child config's connection strings -->
</connectionStrings>
</configuration>
发布于 2014-06-27 20:35:32
我把所有的东西都放在:
<location path="." inheritInChildApplications="false">
....
</location>
除了:<configSections/>
,<connectionStrings/>
和<runtime/>
。
在某些情况下,我们不想从<configSections />
继承一些<section/>
,但是我们不能将<location/>
标记放入到<secionGroup />
中,所以我们必须创建一个secions,并将不需要的部分放入该组中。以后可以将横断面组插入到位置标记中。
所以我们必须改变这一点:
<configSections>
<section name="unwantedSection" />
</configSections>
进入:
<configSections>
<sectionGroup name="myNotInheritedSections">
<section name="unwantedSection" />
</sectionGroup>
</configSections>
<location path="." inheritInChildApplications="false">
<myNotInheritedSections>
<unwantedSection />
</myNotInheritedSections>
</location>
https://stackoverflow.com/questions/782252
复制相似问题