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

MapRoute(正则表达式

  string name,   名称url

  string url,URL  模式spa

  object defaults,  默认值code

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

  string[] namespaces    命名空间路由

string

若是一个URL可以在多个路由中匹配,则默认使用第一个匹配的路由io

              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}"}
            );
相关文章
相关标签/搜索