路由表详解

    context.MapRoute(
                name: "Test1",   //路由名称 唯一
                url: "Admin/{controller}/{action}/{year}/{month}/{day}", //URL规则(分区需增加区域名称常量,此处为Admin)
                defaults: new { controller="Home",action="Index" },   //默认值
                constraints: new  { year=@"\d{4}",month=@"\d{2}",day=@"\d{2}"},  //约束 此处限制年 需为4位数字
                namespaces: new string[] { "TestAreas.Areas.Admin.Controllers" }  //命名空间,有分区时,为了避免多个控制器重名,主项目也需增加namespaces
                );

 

posted @ 2017-12-03 11:23  C小小  阅读(874)  评论(0编辑  收藏  举报