asp.net web api - C# WebApi2 action not found -


i have action:

    [actionname("find")]     [httpget]     public override ihttpactionresult find(string number)     {         //get customer number...     } 

this route:

        config.routes.maphttproute(             name: "apibyaction",             routetemplate: "api/{controller}/{action}",             defaults: new { action = "get" }         ); 

this trace:

system.web.http.request;;;http://localhost:12345/api/customers/find?number=100   system.web.http.controllers;defaulthttpcontrollerselector;selectcontroller;route='controller:customer,action:find' system.web.http.controllers;defaulthttpcontrollerselector;selectcontroller;customer system.web.http.controllers;httpcontrollerdescriptor;createcontroller; system.web.http.controllers;httpcontrollerdescriptor;createcontroller;customercontroller system.web.http.controllers;customercontroller;executeasync; system.web.http.action;apicontrolleractionselector;selectaction; system.web.http.action;apicontrolleractionselector;selectaction; system.web.http.controllers;customercontroller;executeasync; system.net.http.formatting;defaultcontentnegotiator;negotiate;type='httperror', 

however, action not found. route incorrect?

add segment "number" , define defaults controller , number (set optional). should work.

example:

config.routes.maphttproute(             name: "apibyaction",             routetemplate: "api/{controller}/{action}/{number}",             defaults: new { number = routeparameter.optional }         ); 

hope helps. have nice day,

alberto


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -