Daniel Harris

Coding, The Cloud, and Tech

8. May 2012 21:24
by Daniel Harris

Prevent nested Applications from inheriting their parents web.config values in IIS

8. May 2012 21:24 by | 0 Comments

Sometimes you need to host an application within an existing website/app in IIS. The way many of us are all familiar with is right clicking on a folder in the IIS site structure, and choosing 'Convert to Application'. Some expect that this treats the application as a separate entity to it's parent site that it is hosted in. However, any nested applications will still attempt to inherit the parent web.config. This can cause issues. One specific example that affected me was a line that defined the Theme in the parent site, that wasn't present in the child Application. To solve this, simply wrap any sections, or if you prefer the entire web.config (inside the <configuration> node) and the child will no longer inherit settings in the parent web config. <location path="." inheritInChildApplications="false"> This can be particularly useful when apps use common names for entries, such as 'ConnectionString' Personally I try to avoid this and use a more specific name Here is an example of my parent web.config with the new tag to prevent inheritance. <configuration> <location path="." inheritInChildApplications="false"> <system.web> <pages theme="ParentSiteTheme"/> </system.web> </location> <connectionStrings> <!--Shared Information to be inherited--> </connectionStrings> </configuration>