MVC Area and controller with the same name

1.4k Views Asked by At

I am working on MVC3 application. My folder structure for the application is:

Areas
    Admin
        Controller
            AdminController

The AdminController has an EditUser method. To go to this method, I have to use the following URL:

http://localhost/Admin/Admin/EditUser

I like the folder structure of the application, but I want to get away with typing Admin twice in the URL. I want the URL to look like:

http://localhost/Admin/EditUser

How would I be able to do this? I am looking into routing, but need more clarification regarding this. Any help would be appreciated.

UPDATE: Ok, so I have added the following to the Routing information under Global.asax.cs file.

routes.MapRoute("Admin",
    "Admin/Admin/{action}/{id}",
    new { action = "Index", id = UrlParameter.Optional }
    );

This takes me to the correct controller method, but the view cannot be found when i use the following statement:

return View();

Do I need to add something in the area registration as well for this to work?

0

There are 0 best solutions below