Click here to Skip to main content
15,896,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
iam see this error
Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{Controller}/{action}/{id}') 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.

The request for 'Home' has found the following matching controllers:
Web.Areas.BaseAdmin.Controllers.HomeController
Web.Controllers.HomeController
C#
public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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

         routes.MapRoute(
              name: "baseadmin",
           url: "BaseAdmin/Home/{action}/{id}",
              defaults: new
              {
                  controller = "BaseAdmin/Home",
                  action = "Index",
                  issueId = UrlParameter.Optional,
                  projectId = UrlParameter.Optional
              }
          );
      }
  }
Posted
Updated 9-Apr-19 0:47am

1 solution

C#
you can mention the namespace in the route config as explained below:

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

         routes.MapRoute(
              name: "baseadmin",
           url: "BaseAdmin/Home/{action}/{id}",
              defaults: new
              {
                  controller = "BaseAdmin/Home",
                  action = "Index",
                  issueId = UrlParameter.Optional,
                  projectId = UrlParameter.Optional
              },
           namespaces:Web.Areas.BaseAdmin.Controllers
          );
C#

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900