Block Inheritance of Root web.config for Child Applications

10. January 2008 00:10

I ran across a situation working on an Intranet application where I did not want a sub directory (which was a seperate web application) to inherit the parent/root web applications web.config settings.  I searched around and found an article about the lock attributes for sections and elements in the web.config, but that was not working.  Basically what was happening is that when I went to the sub application via http://mainsite/subApp the subApp would fail because it said it couldn't find a reference to a setting I had in my root applications web.config (in my case it was a tagMapping and HttpModule settings).

The following takes care of this type of situation.

In the root web.config file I wrapped my <system.web> section with the following tags:

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

This allows all child applications to use its web.config only and not worry about anything in the parents web.config.  The following URL is an MSDN article about it:

http://msdn2.microsoft.com/en-us/library/system.configuration.sectioninformation.inheritinchildapplications.aspx

Tags: ,

ASP.NET




My Random Thought

I think the OCW is a great thing to have available to those who are in school, just finished school or just want to educate themself

http://ocwconsortium.org/

John On Twitter

Discounts