.net core mvc 区域路由设置(配置)
程序员文章站
2022-05-14 18:20:37
写博客原因:添加了区域(用作后台)后,报错: 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}" );
二.>>然后再给区域控制器添加如下:
上一篇: 新站做好关键词优化的五大注意点分享
下一篇: php 图片上传类代码