寫博客原因:添加了區域(用作後臺)後,報錯: An unhandled exception occurred while processing the request.AmbiguousActionException: Multiple actions matched. The following ...
寫博客原因:添加了區域(用作後臺)後,報錯:
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}" );
二.>>然後再給區域控制器添加如下: