.net core mvc 区域路由设置(配置)
生活随笔
收集整理的這篇文章主要介紹了
.net core mvc 区域路由设置(配置)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
寫博客原因:添加了區域(用作后臺)后,報錯:
An unhandled exception occurred while processing the request.
AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:
CompanyHome.Controllers.HomeController.Index (CompanyHome)
CompanyHome.Areas.Manage.Controllers.HomeController.Index (CompanyHome)
不是很明白,大概是找不到進入那個路由吧,命名空間沖突。
總覽:
一.>>先在Startup.cs中添加對區域路由的路徑,如圖紅框內
代碼如下:
routes.MapRoute(name: "areaname",template: "{Manage:exists}/{controller=Home}/{action=Index}/{id?}");routes.MapAreaRoute(name: "Manage",areaName: "Manage",template: "Manage/{controller=Home}/{action=Index}");二.>>然后再給區域控制器添加如下:
?
轉載于:https://www.cnblogs.com/zx3180/p/9547834.html
總結
以上是生活随笔為你收集整理的.net core mvc 区域路由设置(配置)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ngrep 比 tcpdump 更方便查
- 下一篇: qt 提高图片加载速度