Avoiding “Request matched multiple actions resulting in ambiguity” error in ASP.Net Core

a 夏天 提交于 2019-12-05 08:05:12

Make your base controllers abstract. Otherwise, they participate in routing as possible controllers that can be routed to. Although I'm a little surprised, honestly, that the routing based on controller name convention still works with a class ending in ControllerBase instead of just Controller, it would appear that ASP.NET Core sees them both as named DevTest, and therefore ambiguous.

You could probably alternatively rename the base controller(s) to something like BaseDevTestController (i.e. with "Base" before "Controller"), which would then make the names DevTest and BaseDevTest, removing the abmiguity. However, it's still a better idea to just make it abstract, as it should be anyways. You wouldn't want someone to actually be able to navigate directly to your base controller(s).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!