We have a typical setup in IIS for our webapp with virtual dirs for different projects:

  • www.webapp.com (Website)
    • project1 (virtual dir)
    • project2 (virtual dir)
    • project3 (virtual dir)

The webapp has login.aspx as a default document, as do all the virtual dirs. Now, I need a different default document (index.aspx) only for the www.webapp.com website. The virtual dirs will continue to use login.aspx and only that.

EDIT: All virtual dirs point to the same physical directory. If I change the default document for www.webapp.com, it is also changed for all underlying virtual dirs.

This used to be easy in IIS 6, but in IIS 7.5 I am unsuccessful to implement this.

I think I need to alter applicationhost.config by adding location tags, but I have no clue how to start. Can someone point me in the right direction?

Thanks! Stijn

To do this you need to modify the the ApplicationHost.config file. The location of the file is currently in the %windir%\system32\inetsrv\config directory.

The Location section towards the end of the document needs to be modified accordingly depending on your app default documents. for eg -

<location path="Default Web Site/App">
    <system.webServer>
        <defaultDocument enabled="true">
            <files>
                <clear />
                <add value="Login.aspx" />
            </files>
        </defaultDocument>
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" />
            </authentication>
        </security>
    </system.webServer>
</location>


<location path="Default Web Site/App/VApp2">
    <system.webServer>
        <defaultDocument enabled="true">
            <files>
                <clear />
                <add value="LoginPage2.aspx" />
            </files>
        </defaultDocument>
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" />
            </authentication>
        </security>
    </system.webServer>
</location>

Maybe I didn't understand your problem, but it seems trivial to me.

Open the Internet Information Services Manager, select the virtual directory (double click). In the IIS section, open "Default Document" and set your default document (or remove some).

Repeat the procedure for all of your virtual directories.

UPDATE:

Question: Do (some of) your virtual directories point to the same physical directory? IIS saves the information in web.config files in the physical directory. That may be your problem.

Workaround: create some logic that redirects the requests of the virtual directories. Or create a copy of your physical directory so that the web.config files can be set individually.

  • indeed, I forgot to mention that they all point at the same physical directory. I'll update the post - Thanks! – Stijn Van Loo Feb 5 '11 at 10:25

Yeah, the easiest (read: cheat-i-est) way of configuring this is to:

Open Feature Delegation, and disable delegation of the Default Document module (or make it read-only) for the site.

With that done, the GUI will create <location> tags for you at any level lower than the Delegation setting you just configured.

1) Go to --> IIS --> virtual directory(double click) -->click Default Document --> click add button --> Enter your html,aspx,..etc For (example index.html , k.html )

2)Go to your physical directory --> open your web.config file with (notepad ++)

3)delete all lines

4)add this lines

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="XX">
       <system.webServer>
       <defaultDocument enabled="false">
         <files>
            <clear />
              <add value="XXX.html" />
         </files>
        </defaultDocument>
    </system.webServer>
    </location>
    </configuration>

5)Edit some changes

<location path="XX">

XX --> your virtual directory name

 <add value="XXX.html" />

XXX.html--> your page name with extension

New contributor
sri kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.