9

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?

4 Answers 4

6

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>
1
  • You can only do it by creating the application in another directory, or change the settings back. Apr 22, 2009 at 18:58
4

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
  • 2
    but what about the sections outside of system.web? like <system.webServer>
    – Blankman
    Apr 23, 2009 at 13:52
  • not 100% sure, but I believe you can wrap anything in a "location". I haven't tried, would definitely need to test it.
    – user1921
    Apr 24, 2009 at 0:39
  • Elements that are only allowed in "root" web.configs can't be wrapped in a "location". Apr 24, 2009 at 9:32
1

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.