使用inheritInChildApplications避免在孩子的Web应用程序的web.config继承 [英] Avoid web.config inheritance in child web application using inheritInChildApplications
问题描述
我想补充
<location inheritInChildApplications="false">
我父web应用程序的web.config,但它似乎并不奏效。
to my parent web application's web.config but it doesn't seem to be working.
我父母的的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设置?
so it ignores all the various web.config settings?
推荐答案
作为评论者所提到的previous答案,你不能简单地添加一行...
As the commenters for the previous answer mentioned, you cannot simply add the line...
<location path="." inheritInChildApplications="false">
...略低于&LT;结构&gt;
。相反,你需要用您要禁用继承个人的web.config部分。例如:
...just below <configuration>
. Instead, you need to wrap the individual web.config sections for which you want to disable inheritance. For example:
<!-- 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>
在&LT;清/&GT;
对于某些配置节的工作,也有一些,而不是需要&LT;删除名称=。 ..&GT;
指令,还有人似乎并不为支持。在这种情况下,它可能是适当的设置 inheritInChildApplications =FALSE
。
While <clear />
may work for some configuration sections, there are some that instead require a <remove name="...">
directive, and still others don't seem to support either. In these situations, it's probably appropriate to set inheritInChildApplications="false"
.
这篇关于使用inheritInChildApplications避免在孩子的Web应用程序的web.config继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!