Prevent ASP.NET web.config inheritance, and inheritInChildApplications attribute

By Jerome at March 23, 2008 12:34
Filed Under: .NET

Since I've changed my top level blog engine, I've had some troubles with YAF, the forum engine I'm using for my Remote Control software.

The forum I'm using is in a child directory, which is a child application defined in IIS as an other application. The BlogEngine.NET disables the use of Sessions, and YAF requires sessions to be enabled, plus BlogEngine.NET adds some custom HTTP handlers, which incidentally are not known but the forum application. This is quite a mess, and to be able to get both applications running without fine tuning each one to work with the other, I had to use the little known attribute inheritInChildApplications.

This attribute prevents an application from passing its configuration as a default to child applications. Using this attribute is a little tricky, and has to be used this way :


<!-- Root web.config file -->

<?xml version="1.0"?>

<configuration>

  <location path="." inheritInChildApplications="false">

    <system.web>

      <compilation debug="false" />

      <!-- other configuration attributes -->

    </system.web>

  </location>

</configuration>

This way, any child application defined below this application will not use the current configuration. There's some mystery around the inheritInChildApplications attribute; it is not defined in the dotnetconfig.xsd file and it still is a rather helpful configuration option...

Comments

5/21/2008 1:55:29 PM #

inheritInChildApplications is only supported in asp.net 2.0 applications. If your child app. is 1.1 an error will be thrown.

DPJ United States

6/24/2008 12:44:02 PM #

Thanks so much for posting this.  I was having this problem of conflicting web.configs affecting applications in subfolders and this seems to fix the problem.

Omar United States

5/1/2009 4:30:32 AM #

Note if you have system.web compilation section in a location tag, you will not be able to run your debugger.

Paul Australia

11/4/2009 7:08:45 PM #

Pingback from exdream.com

How to migrate from dasBlog to BlogEngine.NET!

exdream.com

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading




About me

My name is Jerome Laban, I am a Software developer and .NET enthustiast from Montréal, QC. You will find my blog on this site, where I'm adding my thoughts on current events, or the things I'm working on, such as the Bluetooth Remote Control Software for Windows Mobile.