Will a child application inherit from its parent web.config?

混江龙づ霸主 提交于 2019-12-18 04:48:07

问题


I setup a IIS application from within an existing application.

Will the parents web.config be inherited or is that something I have to set explicitly?


回答1:


Yes it will without setting anything explicitly, and I don't know any way to prevent it.

However many configuration sections will allow you to clear data inherited from parent files.

E.g.

<appSettings>
   <clear/>
   <add key=...>
</appSettings>

<connectionStrings>
   <clear/>
   <add ... />
</connectionStrings>



回答2:


You can also use the remove tag to get rid of things you don't want or put everything in a location and tell it not to inherit:

<remove name="FooBar" />

<location path="." inheritInChildApplications="false">
    <system.web>
        ...
    </system.web>
</location>



回答3:


The child inherits the parent's web.config file.

Also, when a new web.config file is created in the child, the child's web.config file settings override the same settings in the parent's web.config file.




回答4:


What you do is change the parent .NET 4 app's web.config to indicate its settings shouldn't flow down to the children

<location path="." inheritInChildApplications="false">
   <system.web>
    ...your system.web stuff goes here
   </system.web>
</location>

For more details refer here http://www.hanselman.com/blog/ChangingASPNETWebconfigInheritanceWhenMixingVersionsOfChildApplications.aspx



来源:https://stackoverflow.com/questions/778635/will-a-child-application-inherit-from-its-parent-web-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!