routes.MapRoute()定义路由的要求

时间:2018-01-09 20:48:08   收藏:0   阅读:1139

MapRoute(

  string name,   名称

  string url,URL  模式

  object defaults,  默认值

  object constraints,  约束(用正则表达式)

  string[] namespaces    命名空间

如果一个URL能够在多个路由中匹配,则默认使用第一个匹配的路由

              routes.MapRoute(
                     name: "Test5",
                     url: "{year}/{month}/{day}/Details.aspx",
                     defaults: new { controller = "Work", action = "Index", id = UrlParameter.Optional },
                     constraints:new {year=@"\d{4}",month=@"\d{4}",day=@"\d{2}"}
            );

 

原文:https://www.cnblogs.com/atlj/p/8253569.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!