路由机制

URL路由是独立于MVC存在的,在命名空间(System.Web.Routing)命名空间下。

 
MVC路由的作用:1. 从请求中捕获数据;2. 从数据生成虚拟路径
 
Url请求响应流程:
                
MVC路由添加的两种方法:
 
            //路由添加(MapRoute 方法)
            routes.MapRoute("Login""Login.html"new { Controller = "Login", Action = "Index" });
            //路由添加(Add 方法)
            routes.Add(new Route("{Controller}/{Action}/{id}",
                new RouteValueDictionary { {"Controller","Default"},{"action","Index"},{"id","9527"},},
                new MvcRouteHandler()));  
 
注意:由于优先匹配原则,排除路由必须放在注册路由之前,否则是没有效果的。
 
写的不粗:http://blog.csdn.net/yangdaboke/article/details/8735628
posted @ 2019-04-30 22:17  NCat  阅读(235)  评论(0)    收藏  举报