Stopping ASP.NET web.config inheritance

If you are only ever running one ASP.NET application on a website this is not an issue. However, if you are running a site which may have an application at the root and other separate applications running in sub or virtual directories, then Settings inheritance could be a problem.

You can read more about how config files get inherited on msdn but here's a tip for stopping settings in the root app from getting inherited. The tag is the only tag I've come across which has the inheritInChildApplications attribute. So to target the main just wrap it in the location tag as seen below.


Other Notes:
Although I think the inheritance is in general a good feature to have, especially for inheriting down things such as security settings. It can even support locking certain settings for child applications, but things can be problematic if the child application doesn't share the same libraries, modules, handlers, masterpages or themes.

Most collections in the web.config have the tag or tag to remove irrelevant modules or handlers in the child app. The problems I've found occur with settings relating to the tag, which most items in it don't support . This means if your child applications doesn't share or have the same registered controls, masterpages or themes then you are probably going to have issues or be forced to specify the settings on a per-page basis. This is where the inheritInChildApplications="false" really comes in handy.

search this blog (most likely not here)