Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I run my application on localhost I get a directory listing and have to click on 'Index.aspx' to view the page.

I have already set the Set As Start Page to 'Index.aspx', which means when I press 'F5', 'Index.aspx' is opened.

This works fine, but when navigating through the site, if there is a link, such as '/FolderName', I get a directory listing, and have to manually change the URL to '/FolderName/Index.aspx'.

I believe this is because by default, the default page is 'Default.aspx'?

Is it possible to change this to 'Index.aspx'? It would save me a lot of time!

share|improve this question
    
Where do you want to change it -- in web server (IIS 7) or Visual Studio? –  LazyOne Jul 5 '11 at 13:04
    
Visual Studio, IIS is fine as I can use the 'Home Directory' options –  Curt Jul 5 '11 at 13:06
    
TBH I'm not 100% sure if my answer will work in VS (do not currently have one around to check -- you may need to reload project to see changes in VS). –  LazyOne Jul 5 '11 at 13:10

1 Answer 1

Place this into web.config in root folder of your site (if you have one already then just add appropriate section):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="Index.aspx" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

The above will add Index.aspx as the default document. If you want to remove all other default documents -- add <clear /> before <add value="Index.aspx" /> line:

<system.webServer>
    <defaultDocument>
        <files>
            <clear />
            <add value="Index.aspx" />
        </files>
    </defaultDocument>
</system.webServer>
share|improve this answer
    
whoa! +1 to get you past 666 reputation... –  BenGC Jul 5 '11 at 13:10
    
@BanGC LOL! Thnx –  LazyOne Jul 5 '11 at 13:11
    
Wish I could upvote too but hasn't solved my problem :/ I don't understand how this would work anyway as the web.config isn't read when opening a directory? –  Curt Jul 5 '11 at 13:12
    
@Curl These instructions tell web server to use Index.aspx as default document when accessing folder. It should work in VS-bundled server as well (this definitely works in IIS and IIS Express). –  LazyOne Jul 5 '11 at 13:16
    
@Curt I recommend installing IIS Express or even IIS -- msdn.microsoft.com/en-us/library/58wxa9w5.aspx –  LazyOne Jul 5 '11 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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