Monday, 4 February 2008

Disabling Configuration Inheritance For ASP.NET Child Applications

Configuration inheritance is a very robust feature of ASP.NET that allows you to set configuration settings in the Web.Config of a parent application and have it automatically be applied to all of its child applications. There are certain situations, however, when there are configuration settings that you don't want to apply to a child application. The usual course of action is to override the setting in question in the child application's web.config file, which is ideal if there are only a handful of settings to deal with. This is less than ideal when there are a significant number of settings that need to be overridden, or when you simply want the child application to be largely independent of its parent.

There solution is Configuration <location> Settings which allows you to selectively exclude portions of an application's web.config from being inherited by child applications.

<location path="." inheritinchildapplications="false">
<system.web>
...
</SYSTEM.WEB>
</location>
By wrapping the <system.web> element with the <location> element and setting the path attribute to "." and inheritInChildApplications attribute to "false" I prevented every child application of the main web application from inheriting the settings in the <system.web> element.

kick it on DotNetKicks.com

3 comments:

  1. Hi,
    Its very easy to understand article.GOOD.

    ReplyDelete
  2. Hi,
    It's really nice one,superb but is it possible to colour the change grid or not???
    like you saw in trading...
    Abu
    abu_arqam@hotmail.com

    ReplyDelete
  3. I'm pretty sure .net can do all of the things in that list. The question is, how easily... keep posting.......

    ReplyDelete