zoukankan      html  css  js  c++  java
  • C# asp.net mvc 配置多个route 参数

     mvc 中路由可以自定义

    public class RouteConfig
    {
    public static void RegisterRoutes(RouteCollection routes)
    {
    routes.AppendTrailingSlash = true;
    routes.LowercaseUrls = true;
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute("MvcPager_PageSize", "{controller}/{action}/{pagesize}/{pageindex}", new { controller = "Demo", action = "PageSize", pageindex = UrlParameter.Optional }, new { action = "PageSize", pagesize = @"d*", pageindex = @"d*" });
    routes.MapRoute("MvcPager_Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new { id = @"d*" });
    routes.MapRoute("MvcPager_SEO", "{controller}/{action}/page_{id}", new { controller = "Demo", action = "FirstPageUrl", id = 1 }, new { action = "FirstPageUrl", id = @"d*" });
    routes.MapRoute("MvcPager_Pager1", "{controller}/{action}/page_{pageindex}", new { controller = "Demo", action = "CustomRouting", pageindex = 1 }, new { action = "CustomRouting", pageindex = @"d*" });
    routes.MapRoute("MvcPager_Pager2", "{controller}/{action}/pageindex-{pageindex}", new { controller = "Demo", action = "CustomRouting", pageindex = 1 }, new { action = "CustomRouting", pageindex = @"d*" });
    routes.MapRoute("MvcPager_Pager3", "{controller}/{action}/p-{pageindex}", new { controller = "Demo", action = "CustomRouting", pageindex = 1}, new { action = "CustomRouting", pageindex = @"d*" });

    }
    }

  • 相关阅读:
    Leon-ai on WSL
    自动化测试工具
    创建自己的Spring Boot Starter
    Spring Boot内嵌Tomcat session超时问题
    Spring Boot
    Spring Cloud
    Socket编程之Tomcat模拟_采坑汇总
    访问者模式
    模版模式
    策略模式
  • 原文地址:https://www.cnblogs.com/louby/p/5313869.html
Copyright © 2011-2022 走看看