No type was found that matches the controller named 'User'

后端 未结 14 2407
孤城傲影
孤城傲影 2020-12-23 19:49

I\'m trying to navigate to a page which its URL is in the following format: localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx

I\'ve added a new route i

相关标签:
14条回答
  • 2020-12-23 19:52

    In my case I was calling the APi like

    http://locahost:56159/api/loginDataController/GetLoginData

    while it should be like

    http://locahost:56159/api/loginData/GetLoginData

    removed Controller from URL and it started working ...

    Peace!

    0 讨论(0)
  • 2020-12-23 19:57

    In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder. The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found. But I didn't read the whole warning, because I wanted to locate the file to elsewhere.. so that's why it didn't work for me.

    After I added a new controller and let it to be in the App_Code by default, everything worked.

    0 讨论(0)
  • 2020-12-23 20:01

    In my case I was using Web API and I did not have the public defined for my controller class.

    Things to check for Web API:

    • Controller Class is declares as public
    • Controller Class implements ApiController : ApiController
    • Controller Class name needs to end in Controller
    • Check that your url has the /api/ prefix. eg. 'host:port/api/{controller}/{actionMethod}'
    0 讨论(0)
  • 2020-12-23 20:01

    Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.

    0 讨论(0)
  • 2020-12-23 20:01

    In my solution, I have a project called "P420" and into other project I had a P420Controller.

    When .NET cut controller name to find route, conflict with other project, used as a library into.

    Hope it helps.

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

    In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:

    My route defined in WebApiConfig.cs was like this:

    config.Routes.MapHttpRoute(
        name: "ControllersApi",
        routeTemplate: "{controller}/{action}"
    );
    

    and it should be like this:

    config.Routes.MapHttpRoute(
        name: "ControllersApi",
         routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
    );
    

    as you see it was interfering with the standard route defined in RouteConfig.cs.

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