저는 프로젝트에 두 개의 영역이 있습니다. 내가 여기에 몇 가지 소스를 발견'Home'컨트롤러와 일치하는 여러 유형이 발견되었습니다. - 두 개의 다른 영역에서
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:
BaseAdminMVC.Areas.BaseAdmin.Controllers.HomeController
BaseAdminMVC.Areas.TitomsAdmin.Controllers.HomeController
: 나는이 프로그램을 실행할 때 지금은이 오류를 얻을 Multiple Controller name
을하지만 그것은 단지 하나 개의 영역 작동 생각합니다.
제 경우에는 다른 영역에 두 개의 프로젝트가 있습니다. 누군가가 문제를 해결하기 위해 무엇을해야하는지 말할 수 있기를 바랍니다.
가 여기에 Global.asax
파일입니다
public static void RegisterRoutes(RouteCollection routes)
{
string[] namespaces = new string[] { "BaseAdminMVC.Areas.BaseAdmin.Controllers", "BaseAdminMVC.Areas.TitomsAdmin.Controllers"};
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces
);
}
그런데, 나는 또한 Area
폴더 외부 ("HomeController
")를 컨트롤러했다. 이것은 단지 두 개의 프로젝트 BaseAdmin
과 TitomsAdmin
에 대한 링크를 제공합니다.
나는이 솔루션을 시도,하지만 여전히 는 작동하지 않습니다
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
"BaseAdmin",
"BaseAdmin/{controller}/{action}",
new { controller = "Account", action = "Index" },
new string[] { "BaseAdminMVC.Areas.BaseAdmin.Controllers" }
);
routes.MapRoute(
"TitomsAdmin",
"TitomsAdmin/{controller}/{action}",
new { controller = "Home", action = "Index" },
new string[] { "BaseAdminMVC.Areas.TitomsAdmin.Controllers" }
);
사전에 감사!
편집 : 기본 경로를 아래로 (마지막 위치로) 이동해야합니다. 여기에서 주문이 중요합니다. –
@HenkHolterman 여전히 작동하지 않았다. – fiberOptics
"작동하지 않는다"는 것은 아직 명확하지 않습니다. –