我尝试了ASP.NET MVC路由,当然有偶然发现一个问题。我有一个部分/ Admin/Pages /,这也可以通过/ Pages /访问,它不应该访问它。我可能会错过什么?Asp.net MVC路由不明确,两个路径相同的页
在Global.asax中路由代码:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Pages", // Route name
"Admin/Pages/{action}/{id}", // URL with parameters
// Parameter defaults
new { controller = "Pages", action = "Index", id = "" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
// Parameter defaults
new { controller = "Home", action = "Index", id = "" }
);
}
谢谢!
这应该是答案,因为意图是保护PagesController的Index操作方法。 – 2014-09-23 05:36:24