Getting Started with IIS7 (Part 2)
Part 1 of this series you learnt the common tasks such as application
pool management, web site creation and IIS application creation. In this part I
will discuss about the hierarchical configuration system used by IIS7 along with
In the previous versions of IIS the configuration used to reside in what is
known as IIS metabase. The metabase file was a binary file under IIS 5.x and an
XML file under IIS6. Still it was a sort of monolithic with very little control.
The IIS7 provides a whole new configuration model that is much more flexible and
allows for configuration inheritance and overriding easily.
All the IIS metabase information is now stored in a file named
applicationHost.config. This file resides in \Windows\System32\InetSrv\config
folder. This file contains a list of all websites and IIS applications
configured under your web server. Have a look at the markup below (unwanted
markup removed for better readability):
<add name="MyNewPool" autoStart="true" />
<site name="MyWebSite" id="2">
The <system.applicationHost> section stores the information about IIS
websites. The <applicationPools> section stores information about application
pools whereas <sites> section stores information about web sites, IIS
applications and Virtual Directories.
The applicationHost.config file also stores default settings for web sites
and virtual directories under <system.webServer> section (see below).
<caching enabled="true" enableKernelCache="true">
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
<directoryBrowse enabled="false" />
One interesting fact about the applicationHost.config file is that it is
based on the same model as web.config files. This means you can use web.config
of an IIS application to override settings from the applicationHost.config file.
Ok. Now that you know how IIS7 stores its configuration, let's understand how
ASP.NET related configuration is inherited and overridden.
Inheriting and Overriding ASP.NET Configuration
The mechanism of configuration inheritance and overriding can be best
understood with an example. Open IIS manager and select the root web site.
Locate "Application Settings" option from the Workspace pane and add a new
key-value pair as shown below:
Where does this configuration gets stored? Locate \Windows\Microsoft
.NET\Framework\<version>\Config folder. There you will find a web.config file.
If you open it in Notepad you will see an <appSettings> section as shown below:
<add key="Key1" value="Value1" />
Now, select MyWebSite web site under Web Sites folder (recollect that we
created MyWebSite in the Part 1 of this series). Locate Application Settings
option under Workspace pane. If you double click on it you will find a key with
name key1 automatically listed.
This means the settings from the root web site got inherited in the child web
Now, double click on Key1 from the child web site and change the value to
ValueNew. Navigate to the physical folder of MyWebSite. There you will find a
web.config file with the following markup.
<remove key="Key1" />
<add key="Key1" value="ValueNew" />
As you can see the child web.config file overrides the Key1 setting of the
parent web.config. The same inheritance and overriding concept is applicable for
MyWebSite and MyWebApp.
As discussed above IIS7 allows developers to override sections from
applicationHost.config from web.config file. However, what if you want to
prohibit this behavior? Luckly, IIS7 provides what is known as Feature
Delegation that allows you to control this aspect.
Select the root web site under Connections pane. Then double click on Feature
Delegation under Workspace pane to open Feature Delegation section as shown
As you can see the Feature Delegation section lists all the features that can
be configured. The Actions pane contains options to control the operation that
can be performed on them (Read Only, Read and Write etc.). Click on "Read Only"
to mark this section as a read only section i.e. child web sites cannot override
Next, navigate to MyWebSite and double click on Application Settings. This
time you will get an error as shown below:
Ok. That's it! To summarize we can conclude that the IIS7 architecture and
features are more flexible and powerful than its previous versions.
This page is protected by copyright laws.
Copying in any form is strictly prohibited.