Getting “No type was found that matches the controller named 'SampleSlashBaseService'” when trying to use WebAPI

▼魔方 西西 提交于 2019-11-29 09:11:15
azzlack

Found the problem.

ApiControllers class names need to be suffixed with "Controller", and mine was not. Changing it to SampleSlashBaseController solved the problem.

NOTE: It is possible to suffix it with "Service" as I did, but then you have to implement a custom IHttpControllerSelector like described here: http://netmvc.blogspot.no/2012/06/aspnet-mvc-4-webapi-support-areas-in.html

You also need to make sure the Controller class is Public

In my case the Controller was defined properly, but was not marked public.

In my case, there were two controllers with the same name, in different folders. Renaming them solved the problem instantly.

For what it's worth, I ran into this and my problem was my manually-added class wasn't inheriting from ApiController. The class definition needs to be public class QueueController : ApiController not public class QueueController. What a dumb thing to overlook.

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