ISSUE :
 
Profile photo
Submitted by RaKumar
on August 16th, 2012 at 10:52:56 EST

Restrict inheriting web.config values to child application in ASP.NET

I have multiple ASP.NET application running in same IIS. All my applications were running in .NET 2.0. Now I am upgrading the application running in root of IIS to ASP.NET 4.0. After the upgrade I get error with <compilation debug="true" targetFramework="4.0">. Child applications running in .NET 2.0 is not understanding attribute targetFramework="4.0". Is there anyway to restrict my web.config in root website to disallow inheriting values?


Profile photo
Replied by SBajra
on August 16th, 2012 at 12:47:00 EST
To stop or avoid web.config inheritance, there is new feature in ASP.NET 4.0 called inheritInChildApplications. This is an attribute of <location> element of web.config schema. you can use it like <location inheritInChildApplications="false">. You can wrap any web.config group with this <location> element.

For example, you can add in web.config for root ASP.NET application something like this to avoid web.config inheritance.

<location inheritInChildApplications="false">
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
</system.web>
</location>

You can also apply <location> to entire web.config

<configuration>
<location inheritInChildApplications="false">
<appSettings>
</appSettings>
<connectionStrings/>
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
</system.web>
</location>
</configuration>
Accepted Answer
Accepted
 Answer

Profile photo
Replied by RaKumar
on August 16th, 2012 at 13:18:29 EST
This is exactly what I am looking for. You saved my day :)