我需要在新区域中放置一个新家,但我有一个错误:找到了与名为“Home”的控制器匹配的多种类型。如果服务此请求的路由 ('{controller}/{action}/{id}') 未指定命名空间来搜索与请求匹配的控制器,则可能会发生这种情况。如果是这种情况,请通过调用采用“namespaces”参数的“MapRoute”方法的重载来注册此路由。我的新区
区域/行政/控制器/家庭控制器
领域/行政/观点/首页
我的 AdministrativoAreaRegistration
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Administrativo_default",
"Administrativo/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
在全球我有
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new[] { "Preparacao.Gerenciar.Web.Controllers" } // Parameter defaults
);
}