Having issue with multiple controllers of the same name in my project

The error message contains the recommended solution: “If this is the case, register this route by calling an overload of the ‘MapRoute’ method that takes a ‘namespaces’ parameter.”

routes.MapRoute(
     "Default", // Route name
     "{controller}/{action}/{id}", // URL with parameters
     new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
     new string[] { "MyCompany.MyProject.WebMvc.Controllers"}
);

This will make http://server/ go to your HomeController’s Index action which is, I think, what you want. http://server/company/home will go to the Company area’s HomeController’s Index action, as defined in the area registration.

Leave a Comment