我在MVC5应用程序中的路由有问题。
我定义了很多路线,但我没有使用MapMvcAttributeRoutes。
// redirect module
routes.MapRoute(
name: "Redirect",
url: "{category}/{product}",
defaults: new { controller = "Redirect", action = "RedirectUrl", product = UrlParameter.Optional, culture = String.Empty },
constraints: new { category = @"^(?!Category$|Content$)(\w{3,})$" }
);
// --------- DEFAULT ---------
// should be always at the end
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, culture = String.Empty },
constraints: new { controller = @"\w{3,}" }
);
routes.MapRoute(
name: "DefaultLang",
url: "{culture}/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
constraints: new { culture = @"\w{2}" }
);
我想"重定向"路线捕获地址如" / same-day / red-car"。但主要问题是破灭。当我用下划线替换破折号时,它正在工作。
请发一些建议。