In my previous post, I talked about a new feature in IIS 7 which allows the website developers (or owners) to change the default website themselves without engaging the administrator again and again. In this post, I am going to explain how to do that? This is fairly simple.
If you are an Admin, follow the below steps:
1. Open the applicationHost.config file present in %WinDir%/system32/inetsrv/config
2. Under <configSections>, you will find the sectionGroup System.WebServer
3. The section “defaultDocument” overrideModeDefault property should be “Allow”
a. If it is “Deny”, then the settings in the web.config of the all the websites will not take effect.
Now, you will have a question, how do I make only one website to take the default document from the web.config, but not the others? This is really a very good question and this will be the case most of the time. For this, you can select the sites which should not over ride the settings in applicationHost.config. For our example, one of our website should not define the default document in its web.config. Place the below code in the bottom of the applicationHost.config file (just above the </configuration> - that’s the good place to put all the configurations specific to each website)
<location path="Default Web Site" overrideMode="Deny">
You need to do the same if you want to deny the website changing the authentication methods, et all. You can check this article which talks about how to use locking in IIS 7 configuration.
If you are a developer (or the owner of the website), follow the below steps:
1. Confirm with your administrator whether he had followed the above mentioned steps for your website.
2. In the web.config file of your website, you will have to place the <defaultDocument> section below <system.webServer> section group.
<add value="myFile.aspx" />
Also, if you want to place a file which is inside another virtual directory under this website, then you should place <add value="VDir/myFile.aspx" /> as opposed to placing “/VDir/myFile.aspx”.
Now, if you are a developer, you will definitely accept that IIS 7 is a good friend of the developers. But, if you explore more about IIS 7, you will definitely consider IIS 7 as your best friend!