c# - Get and Post methods not working in Web API Controller -


i have post method in controller works fine. want include 1 more method in same controller list of records. unable records. if write method in different controller works fine when include same method in existing controller gives error 'failed load resource: server responded status of 405 (method not allowed)'. here code of controller:

using myapp.entity.models; using newtonsoft.json.linq; namespace myapp.server.controllers { [routeprefix("api/dashboard")]     public class memberscontroller : baseappcontroller     {         public memberscontroller()         {         }         public memberscontroller(httpcontext current)         {             httpcontext.current = current;         }         [allowanonymous]         public string postmemberdetails(jobject memberdata)         {         //my code here         }         [allowanonymous]         public list<myapp.entity.models.registeredmembers> get(bool isregistered)         {         //my code here         }     } } 

and route config code:

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

what going wrong here?

rename post method "post" , both methods should work.

if not configured otherwise, webapi should have actions named method types named get/post etc.


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 -