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

后端 未结 5 444
我在风中等你
我在风中等你 2020-12-18 19:20

I have a webapi project with a base ApiController named SlashBaseService:

[RouteArea(\"uBase\")]
public abstract class SlashBaseService : ApiController
{
}
<         


        
相关标签:
5条回答
  • 2020-12-18 19:42

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

    0 讨论(0)
  • 2020-12-18 19:47

    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

    0 讨论(0)
  • 2020-12-18 19:55

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

    0 讨论(0)
  • 2020-12-18 20:00

    You also need to make sure the Controller class is Public

    0 讨论(0)
  • 2020-12-18 20:02

    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.

    0 讨论(0)
提交回复
热议问题