先說startup中的路由
這里是我們現在用的默認路由,但是在使用當中也有麻煩。總而言之 用的不爽。
使用屬性路由:RouteAttribute特性
默認的HomeController下面的Index訪問url路徑是: home/index
但是有時候我不想這么干我就想裝個B咋辦
ok很簡單index代碼更改如下
[Route("zhuangb/index")] public IActionResult Index() { return View(); }
這樣就可以訪問 zhuangb/index了
標記替換
可以使用標記替換
路由模板參數
https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/routing?view=aspnetcore-2.1#route-template-reference