The Forgotten Web.Config Inheritance Elegance
When you are running multiple Web Applications on a server you sometimes bumped into a challenge that the web.config are cumulative. This can make life sweet for some things, for example you only need to specify the SMTP server settings once, in the root web.config.
There can be other times when you wish to have only a percentage of the parent web.config inherited into your application. The magic control element is <location>.
You may put this around any child element of <configuration>(remembering to keep it valid XML) and then include or exclude elements.
<configuration> <location path="PublicSite"> <system.web> <!-- settings for "PublicSite" go here... --> </system.web> </location> <location path="PrivateSite"> <system.web> <!-- settings for "PrivateSite" go here... --> </system.web> </location> <location path="." inheritInChildApplications="false"> <system.web> </system.web> </location> </configuration>
The MSDN Documentation is here. It applies to Net 2.0 and later. It would be nice if it could be placed around any element .. hint hint hint to MSFT.
Comments
Post a Comment