views:

3442

answers:

4

When I build and run my application I get a directory listing in the browser (also happens for sub folders), and I have to click on Index.aspx. It's making me crazy.

Visual Studio 2008 ASP.NET Development Server 9.0.0.0

+1  A: 

Go to the project's properties page, select the "Web" tab and on top (in the "Start Action" section), enter the page name in the "Specific Page" box. In your case index.aspx

Philippe Leybaert
Yup, that works for the start page, but when I browse to anything in a sub folder I get a folder listing again.
Dan Williams
It's not possible to specify a default page in Visual Studio's internal webserver (Cassini)
Philippe Leybaert
It's working as expected for several of the other developers in my group
Dan Williams
The built-in webserver is hardwired to use Default.aspx as the default page. Maybe your team members are using Default.aspx instead of index.aspx? Or maybe they're using the local IIS on their machine for development.
Philippe Leybaert
+4  A: 

Right click on the web page you want to use as the default page and choose "Set as Start Page" whenever you run the web application from Visual Studio, it will open the selected page.

James Conigliaro
Yup, that works for the start page, but when I browse to anything in a sub folder I get a folder listing again.
Dan Williams
A: 

If you are running against IIS rather than the VS webdev server, ensure that Index.aspx is one of your default files and that directory browsing is turned off.

Garry Shutler
Nope, I'm running the VS webdev server.
Dan Williams
+1  A: 

The built-in webserver is hardwired to use Default.aspx as the default page.

The project must have atleast an empty Default.aspx file to overcome the Directory Listing problem for Global.asax.

:)

Once you add that empty file all requests can be handled in one location.

public class Global : System.Web.HttpApplication
{
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        this.Response.Write("hi@ " + this.Request.Path + "?" + this.Request.QueryString);
        this.Response.StatusCode = 200;
        this.Response.ContentType = "text/plain";

        this.Response.End();
    }
}
zproxy