NikolaiDante NikolaiDante - 1 year ago 145
C# Question

Set "Homepage" in Asp.Net MVC

In MVC the "homepage" (ie the route that displays when hitting is set to Home/Index .

  • Where is this value stored?

  • How can I change the "homepage"?

  • Is there anything more elegant than using RedirectToRoute() in the Index action of the home controller?

I tried grepping for Home/Index in my project and couldn't find a reference, nor could I see anything in IIS (6). I looked at the default.aspx page in the root, but that didn't seem to do anything relevent.


Answer Source

Look at the Default.aspx/Default.aspx.cs and the Global.asax.cs

You can set up a default route:

            "Default", // Route name
            "",        // URL with parameters
            new { controller = "Home", action = "Index"}  // Parameter defaults

Just change the Controller/Action names to your desired default. That should be the last route in the Routing Table.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download