No HTTP resource was found that matches the request URI in Web API

前端 未结 4 1139
闹比i
闹比i 2021-02-03 21:15

I have configured my WebApiConfig like this:

public static void Register(HttpConfiguration config)
{
    config.Routes.MapHttpRoute(
        name: \"DefaultApi\"         


        
4条回答
  •  灰色年华
    2021-02-03 21:41

    Your request URL is http://localhost:8598/api/WebApi/GetLocationCategory/87

    Your route is configured to accept: 'api/{controller}/{action}/{id}'

    So you need to ensure that the name of your controller is 'WebApiController'.

    Also, as stated alredy by @SDG you need to make sure that the name of the parameter to your action method matches what you have in your Route template i.e change 'CatID' to 'id'

提交回复
热议问题