标签:kong test arp ble asp back work href cti
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}", //相当 kong + {controller} +{controller}/{action}+{controller}/{action}/{id}
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
1所以有以上的路由规则,一定要写在Defalut之前,否则会被拦截,
2路由不会先检测常量,只会由上至下,依次匹配,匹配到了,再对比规则,然后再匹配规则(常量的严格匹配),
所以"/students/Details.aspx"会先被【2】截获,然后常量又不匹配,进而报错
////【2】测试{name}-{age} routes.MapRoute( name: "Test4", url: "{name}-{age}", defaults: new { controller = "Work", action = "Index", id = UrlParameter.Optional } ); //【5】测试{table}/Details.apx routes.MapRoute( name: "Test8", url: "{table}/Details.aspx", defaults: new { controller = "Work", action = "Index" } );
3 controller action id都有默认值,所以href="/blogs/tom/news" 匹配的是规则【2】,规则有,而URL无的时候,取默认值,被2截获
//【2】测试字面量和常量必须严格匹配 routes.MapRoute( name: "Test2", url: "blogs/{author}/{category}/{id}", defaults: new { controller = "Work", action = "Index2", id = UrlParameter.Optional } ); //【3】测试字面量和常量必须严格匹配 routes.MapRoute( name: "Test5", url: "blogs/{author}/{category}", defaults: new { controller = "Work", action = "Index5", id = UrlParameter.Optional } );
4 "/blogs/tom/news/1" 匹配的是【3】规则无,而rul有的话,继续找。
//【2】测试字面量和常量必须严格匹配 routes.MapRoute( name: "Test5", url: "blogs/{author}/{category}", defaults: new { controller = "Work", action = "Index5", id = UrlParameter.Optional } ); //【3】测试字面量和常量必须严格匹配 routes.MapRoute( name: "Test2", url: "blogs/{author}/{category}/{id}", defaults: new { controller = "Work", action = "Index2", id = UrlParameter.Optional } );
标签:kong test arp ble asp back work href cti
原文地址:http://www.cnblogs.com/tianxiaoxiao/p/7923070.html