Jest to prawdopodobnie duplikat dla wielu, ale oczywiste odpowiedzi w nich nie rozwiązują mojego problemu.Znaleziono wiele typów pasujących do kontrolera o nazwie "Strona główna". (Dwa obszary, ta sama nazwa kontrolera)
uzyskać:
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:
App.Web.Controllers.HomeController
App.Web.Areas.Mobile.Controllers.HomeController
mam ustawić domyślnej przestrzeni nazw dla mojego HomeController w Global.ascx.cs:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new string[] { "App.Web.Controllers.HomeController" }
);
(Verified że App.Web.Controllers.HomeController nie jest literówka).
A także zarejestrowany HomeController mobilnego w MobileAreaRegistration:
public override void RegisterArea(AreaRegistrationContext context) {
context.MapRoute(
"Mobile_default",
"Mobile/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Dlatego, dlaczego jest tak, że wciąż widzę komunikat o błędzie? Zbudowałem/wyczyściłem i znowu biegnąłem. Wciąż ten sam wynik.
ten sposób mogę zarejestrować swoje trasy:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
W jakiej kolejności więc rejestrujesz trasy? Może mógłbyś pokazać pełny kod rejestracyjny? – Jan