Why ASP.NET MVC bothers to have a Default.aspx file?

When create a new ASP.NET MVC project in Visual Studio 2008, there is a Default.aspx page by default. It has one line

In its Page_Load function, it just redirects to "/" to go through the routing procedure.

    public void Page_Load(object sender, System.EventArgs e)
    {
        HttpContext.Current.RewritePath(Request.ApplicationPath);
        IHttpHandler httpHandler = new MvcHttpHandler();
        httpHandler.ProcessRequest(HttpContext.Current);
    }

I tried to remove Default.aspx and it turns out that the default URI "http://localhost:2574/" is still accessible. So, why bother to have such Default.aspx?

Answers


Older versions of IIS need a startup document and it also gives you something to right-click on to get the "View in Browser" option.


What's happening here, is that the Url requested (which was Default.aspx) is being re-written to the application root "/" and then transferred off of the Webform HTTP handler and onto the MvcHttpHandler. A request for "/" will match the Default route entry (show further down)... eventually sending us onto one of the route controllers.

useful link here


Need Your Help

Xcode 6.3.1 iPhone simulator looms huge on my screen

ios xcode ios-simulator scale simulator

I just upgraded to Yosemite and Xcode 6.3.1. Now, when I run my iPhone app in the simulator (set for iPhone 5S), it looks like this on my 24" screen:

pygtk glade question: why isn't this simple script working?

python gtk pygtk glade

I've been writing writing a small pygtk application using glade to put together the UIs. I've created several windows already that work, but for some reason this one isn't working. I get the foll...