ASP.NET MVC area namespace problem
Asked Answered
R

1

8

I create a new area in my asp.net mvc 3 solution named admin. Visual studio automatically assign the names space:

MyApp.areas.admin.controllers

I change this to MyApp.admin.controllers

But it stops resolving the action.
Any help in this regard will be appreciated.
Thanks

Rhigolene answered 19/7, 2011 at 19:4 Comment(2)
Why does the namespace matter?Pamilapammi
Have you changed anything else? Moved files, renamed folders, removed the route registration from the area registration file?Alongshore
D
16

You need to specify the new namespace when registering the route for your admin area.

In your \Areas\admin\adminAreaRegistration.cs file, you need to modify the RegisterArea() method as follows:

public override void RegisterArea(AreaRegistrationContext context)
{
    context.MapRoute(
        "admin_default",
        "admin/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional }, 
        new string[] { "MyApp.admin.Controllers" }  // specify the new namespace
    );
}
Dot answered 19/7, 2011 at 19:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.