Prevent ASP.NET web.config inheritance, and inheritInChildApplications attribute -ASP.NET如何防止web.config向下(子应用程序)继承?

来源:互联网 发布:双色球关注数据采集 编辑:程序博客网 时间:2024/06/05 20:54

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...

原创粉丝点击