mvc5新特性RouteAttribute特征路由,本文讲述如何开启mvc5的RouteAttribute路由功能并附上一个实例说明RouteAttribute是怎么工作的
1、mvc5的RouteAttribute概述
RouteAttribute的命名空间是System.Web.Mvc,区别与web api的RouteAttribute(它的命名空间是System.Web.Http)
默认情况下mvc的特征路由(RouteAttribute)功能是关闭的,需要手动启动,启动方式:
2、RouteAttribute简单实例
Route("list.html")匹配地址:http://localhost:2000/list.html
Route("list/{category}.html") 匹配地址:http://localhost:2000/list/news.html
Route("list/{category}/{page:int}.html") 匹配地址:http://localhost:2000/list/bews/2.html