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

后端 未结 14 2469
孤城傲影
孤城傲影 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 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.

提交回复
热议问题