c# - Post and Get request method issue -
c# - Post and Get request method issue -
i having issues getting both request work together.
when utilize [fromuri], unable filter post request in fiddler able phone call request in browser.
but when utilize [frombody], unable request method able filter post request, in fiddler.
(e.g. request --> localhost/api/test?name=bbcm)
(e.g. post request: [request header] --> user-agent: fiddler content-type: application/json; host: localhost:45361 content-length: 16 authorization: basic #####= [request body] --> {"name":"bbcm"})
[authorize] [httpget] [httppost] public httpresponsemessage post([fromuri] query query) { // var info = data.tolist(); if (!data.any()) { var message = string.format("no info found"); homecoming request.createerrorresponse(httpstatuscode.notfound, message); } homecoming request.createresponse(httpstatuscode.ok, data); } } am calling request incorrectly or need alter of code create work. please advice. many thanks
simply create single post method , single method , private method called both of them. allows take input parameters correctyl desired methods.
you can still access parameters in post method context via request object if need.
c# post asp.net-web-api get
Comments
Post a Comment