我正在尝试ASP.NET MVC路由,当然偶然发现了一个问题.我有一个部分,/ Admin/Pages /,这也可以通过/ Pages /访问,它不应该.我能错过什么?
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 = "" }
);
}
Run Code Online (Sandbox Code Playgroud)
谢谢!