Routing
假如有一個(gè)請(qǐng)求:localhost/home/index,那么路由需要做的事情如下:
(1)確定Controller
(2)確定Action
(3)確定其他參數(shù)
(4)根據(jù)識(shí)別出來的數(shù)據(jù),將請(qǐng)求傳遞給Controller和Action
??App_Start文件夾中的RouteConfig類負(fù)責(zé)創(chuàng)建路由規(guī)則
public static void RegisterRoutes(RouteCollection routes)
{routes.IgnoreRoute("{resource}.axd/{*pathInfo}");routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
這里,對(duì)于路由規(guī)則需要注意的有兩點(diǎn):
(1)可以有多條路由規(guī)則;
(2)路由規(guī)則是有順序的(前面的規(guī)則被匹配后,后面的規(guī)則就不再匹配);
MapRoute
轉(zhuǎn)載于:https://www.cnblogs.com/wuyong09/p/5010693.html
總結(jié)
- 上一篇: UINavigationControll
- 下一篇: 包皮环切多少钱啊?