.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 更方便查
- 下一篇: OpenStack配置虚拟机vcpu绑定