当前位置: 萬仟网 > IT编程>开发语言>.net > .net core mvc 区域路由设置(配置)

.net core mvc 区域路由设置(配置)

2018年08月28日  | 萬仟网IT编程  | 我要评论
写博客原因:添加了区域(用作后台)后,报错: 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}"
                    );

二.>>然后再给区域控制器添加如下:

 

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
Copyright © 2017-2021  萬仟网 保留所有权利. 粤ICP备17035492号-1
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com