我在主/顶部区域有一个Contacts控制器,我有一个名为"Contacts"的区域.
如果我在注册顶级路线之前注册我的区域,我会将POST 404s发送到Contacts控制器:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
ModelBinders.Binders.DefaultBinder = new NullStringBinder();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
Run Code Online (Sandbox Code Playgroud)
而且,如果我在路线后注册我的区域,我的404到联系人控制器就会消失,但我到联系人区域的路线现在是404s.
...记录了许多重复的控制器名称问题,但我没有找到该区域与控制器名称相同的特定方案.
...可能很容易解决.很感激帮助.:-D
fwiw,我正在使用显式命名空间注册我的Contacts区域:
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 },
namespaces: new[] { "MyMvcApplication.Controllers" }
);
}
Run Code Online (Sandbox Code Playgroud)