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
Post a Comment