小编use*_*334的帖子

Asp.net MVC路由模糊,同一页面的两条路径

我正在尝试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)

谢谢!

asp.net-mvc routing

5
推荐指数
2
解决办法
2562
查看次数

标签 统计

asp.net-mvc ×1

routing ×1