zoukankan      html  css  js  c++  java
  • 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 路由之前天津唉纸条路由。

  • 相关阅读:
    win2008服务器信任问题
    切换cmd的目录
    c#后的完整cookie
    c#网络编程-第一章
    c#访问mysql数据库
    标准库hashlib模块
    标准库ConfigParser模块
    标准库shutil
    标准库 xml
    标准库shelve
  • 原文地址:https://www.cnblogs.com/tangge/p/6378188.html
Copyright © 2011-2022 走看看