0

Scenario: I have 3 Areas named- Albums, Singers , Music Now each of these areas have controllers with same name. For instance every area has LoginController.

Now currently I am getting following exception

Multiple types were found that match the controller named 'Login' This can happen if the route that services this request does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.

This is auto generated Configuration by Visual Studio on Area Creation

 public override string AreaName 
 {
 get 
 {
 return "Albums"
 }
 }
 public override void RegisterArea(AreaRegistrationContext context) 
 {
 context.MapRoute(
 "Albums_Default"
 "Client/{controller}/{action}/{id}",
 new { action = "Index", id = UrlParameter.Optional }
 );
 }

This is my intial configuration in RoutesConfig.cs

 routes.MapRoute(
 name: "Default",
 url: "{controller}/{action}/{id}",
 defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
 namespaces: new[] { "Application_Name" }
 );

Now how to configure the routes that without any modification in url, the desired view is rendered.

asked Aug 3, 2015 at 11:45

1 Answer 1

1

Please try this one :

 public static void RegisterRoutes(RouteCollection routes)
 {
 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 routes.MapRoute(
 "Default", // Route name
 "{controller}/{action}/{id}", // URL
 new { controller = "Home", action = "Index", id = "" }, // Defaults
 new[]{"AreasDemoWeb.Controllers"} // Namespaces
 );
 }

Help Link 1

Help Link2

answered Aug 3, 2015 at 12:01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.