c# - How to make POST with parameters> -
i try make simple post request webapi:
http://localhost::60310/locations/15
full request are:
https://imgur.com/a/fgguj
my controller:
[produces("application/json")] [route("/locations")] public class locationscontroller : controller { [httppost("{id}")] public async task<iactionresult> putlocation() { var distance= request.form.firstordefault(p => p.key == "distance").value; var city = request.form.firstordefault(p => p.key == "city").value; var place= request.form.firstordefault(p => p.key == "place").value; var county= request.form.firstordefault(p => p.key == "country").value; var id = request.form.firstordefault(p => p.key == "id").value; //some code } }
so, have data class:
public class location { [jsonproperty("distance")] public int distance { get; set; } [jsonproperty("city")] public string city { get; set; } [jsonproperty("place")] public string place { get; set; } [jsonproperty("id")] public int id { get; set; } [jsonproperty("country")] public string country { get; set; } }
when try test request (by postman) have 200 code. but, when make breakpoint method- not work. so, assume, method not call framework.
can me: why method not call?and how fix that?
Comments
Post a Comment