Reputation: 32868
I have an ASP.NET MVC website and an area project called 'Admin'.
So far the routing works fine, except that it seems I can't have 2 controllers with the same name in each project.
I thought the following URLs would both work fine:
But it turns out that I get the following error when accessing either:
The controller name 'Home' is ambiguous between the following types:
MyProject.Website.Controllers.HomeController
MyProject.Admin.Controllers. HomeController
Is this normal, or is there something wrong with my setup?
BTW, here's my routing code:
Main project:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Admin.Routes.RegisterRoutes(routes);
routes.MapAreaRoute(
"Main",
"default_route",
"{controller}/{action}/{URLName}",
new { controller = "Home", action = "Index", URLName = "" },
new string[] { "MyProject.Website" }
);
}
Area project:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapAreaRoute(
"Admin",
"Admin_Default",
"Admin/{controller}/{action}",
new { controller = "Home", action = "Index" },
new string[] { "MyProject.Admin" }
);
}
Upvotes: 2
Views: 496