MVC:分页改进URL

http://localhost/?page=2

   

可以根据"可组合URL"创建一种更具吸引力的URL方案:

http://localhost/page2

   

public static void RegisterRoutes(RouteCollection routes)  

        {  

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");  

    

            routes.MapRoute(  

            name: null,  

            url: "Page{page}",  

            defaults: new { Controller = "Product", action = "List" }  

            );  

    

            routes.MapRoute(  

                name: "Default",  

                url: "{controller}/{action}/{id}",  

                defaults: new { controller = "Product", action = "List", id = UrlParameter.Optional }  

            );  

        }  

   

重要的是在已有的 Default 路由之前天津唉纸条路由。

posted @ 2017-02-08 14:52  【唐】三三  阅读(326)  评论(0编辑  收藏  举报