.net core mvc 区域路由设置(配置)
程序员文章站
2023-02-18 10:49:56
写博客原因:添加了区域(用作后台)后,报错: 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}" );
二.>>然后再给区域控制器添加如下:
上一篇: 怎么学大数据?该从哪学起?
下一篇: Ai怎么绘制饮水机图标?
推荐阅读