使用inheritInChildApplications避免子Web应用程序中的web.config

使用inheritInChildApplications避免子Web应用程序中的web.config继承

我想补充一下

<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设置?


慕码人8056858
浏览 1347回答 3
3回答

慕标5832272

正如前面提到的答案的评论者所说,你不能简单地添加这一行......<location&nbsp;path="."&nbsp;inheritInChildApplications="false">......就在下面<configuration>。相反,您需要包装要禁用继承的各个web.config节。例如:<!--&nbsp;disable&nbsp;inheritance&nbsp;for&nbsp;the&nbsp;connectionStrings&nbsp;section&nbsp;--><location&nbsp;path="."&nbsp;inheritInChildApplications="false"> &nbsp;&nbsp;&nbsp;<connectionStrings> &nbsp;&nbsp;&nbsp;</connectionStrings></location><!--&nbsp;leave&nbsp;inheritance&nbsp;enabled&nbsp;for&nbsp;appSettings&nbsp;--><appSettings></appSettings><!--&nbsp;disable&nbsp;inheritance&nbsp;for&nbsp;the&nbsp;system.web&nbsp;section&nbsp;--><location&nbsp;path="."&nbsp;inheritInChildApplications="false"> &nbsp;&nbsp;&nbsp;<system.web> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<webParts> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</webParts> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<membership> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</membership> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<compilation> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</compilation> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</system.web> &nbsp;</location>虽然<clear />可能适用于某些配置部分,但有些部分需要<remove name="...">指令,而其他部分似乎也不支持。在这些情况下,可能适合设置inheritInChildApplications="false"。
打开App,查看更多内容
随时随地看视频慕课网APP