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

后端 未结 14 2409
孤城傲影
孤城傲影 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 20:02

    In my case, the routing was defined as:

     config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{*catchall}",
                defaults: new { controller = "WarehouseController" }
    

    while Controller needs to be dropped in the config:

     config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{*catchall}",
                defaults: new { controller = "Warehouse" }
    
    0 讨论(0)
  • 2020-12-23 20:12

    In my case it was a case of over-aggressive caching by the WebHostHttpControllerTypeResolver.

    Fix:

    1. Delete all files (or in my case just any files named "MS-ApiControllerTypeCache.xml") under this path:

      C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root

    2. Restart the app pool

    credit: https://sitecore.stackexchange.com/questions/9897/webapi-controllers-not-being-found-in-sitecore-8-2

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

    In my case, the controller was defined as:

        public class DocumentAPI : ApiController
        {
        }
    

    Changing it to the following worked!

        public class DocumentAPIController : ApiController
        {
        }
    

    The class name has to end with Controller!

    Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!

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

    In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.

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

    Another solution could be to set the controllers class permission to public.

    set this:

    class DocumentAPIController : ApiController
    {
    }
    

    to:

    public class DocumentAPIController : ApiController
    {
    }
    
    0 讨论(0)
  • 2020-12-23 20:15

    In my case I was seeing this because I had two controllers with the same name:

    One for handling Customer orders called CustomersController and the other for getting events also called CustomersController

    I had missed the duplication, I renamed the events one to CustomerEventsController and it worked perfectly

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