SYSK 145: Preventing Configuration Setting Inheritance in Web Apps


If you have a website that contains nested ASP.NET web applications, by default, the settings in the root website’s configuration file inherit downward through all of the ASP.NET applications and subdirectories of the site (see http://msdn2.microsoft.com/en-us/library/ms178685.aspx for more information). 


 


One way to enhance application performance, maintain high reliability, and simplify administration is to restrict inheritance of configuration settings. 


The attributes frequently used to achieve that are: allowOverride, lockAttributes, lockAllAttributesExcept, lockAllElementsExcept, lockItem and lockElements (see http://msdn2.microsoft.com/en-us/library/ms228167.aspx for more information).


 


But did you know that you can also use a new (in .NET 2.0) attribute inheritInChildApplications to lock an entire section of settings?  Here is how you’d use it:


 


<location inheritInChildApplications=”false”>


    <system.web>


       <!—Your settings here will not be inherited –>


    </system.web>


</location>


 

Comments (2)

  1. Saumin says:

    hi,

    I have a .net 2.0 application…and within that application, i have a .net 1.1 application. I used this setting in root (.net 2.0 app) web.config to not to inherit settings. but VS 2005 doesnt recognize it and because of this, i cannot debug from VS 2005. Is there any workaround for this? Please let me know.

    Thanks!

    Saumin

  2. A while back, Steve Smith brought up a recurring problem I think most of us have bumped into, which is