Trouble setting a default controller in MVC 2 RC Area

Posted by mannish on Stack Overflow See other posts from Stack Overflow or by mannish
Published on 2010-01-11T23:43:46Z Indexed on 2010/03/24 4:53 UTC
Read the original article Hit count: 515

Filed under:
|

This should be simple, but alas...

I've set up an Admin area within my MVC 2 project (single project areas). I've created a couple controllers and their respective view folders. In the AreaRegistration.RegisterArea method, I've specified that I want the default controller to be "Dashboard":

public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Admin_default",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Dashboard", action = "Index", id = "" }, new string[] { "Admin" }
        );
    }

If I navigate to url/Admin/Dashboard, the index comes up just fine. What I want, though, is to allow the user to go to url/Admin/ and see the same thing. When I do this, however, I get "The resource cannot be found".

I'm just getting my feet wet with MVC 2's Area implementation, and I don't think I'm doing anything overly complicated... Anyone had the same problem? Do I need to specify a separate route, perhaps at the root, non-area level?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about routing