为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕码人8056858 2019-08-26 11:11:30
使用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设置?
查看完整描述

3 回答

?
慕标5832272

TA贡献1966条经验 获得超4个赞

正如前面提到的答案的评论者所说,你不能简单地添加这一行......

<location path="." inheritInChildApplications="false">

......就在下面<configuration>。相反,您需要包装要禁用继承的各个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"


查看完整回答
反对 回复 2019-08-26
  • 3 回答
  • 0 关注
  • 1344 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信