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>