asp.net - Setting up a POST Web API Method? -


i need set web api method accept post parameters sent android , ios client apps. have now:

[httppost] [route("api/postcomment")] public ihttpactionresult postcomment([frombody]string comment, [frombody]string email, [frombody]string actid) {        string status = commentclass.postnewcomment(comment, email, actid);        return ok(status); } 

however doesn't work since believe method cannot take multiple [frombody] parameters @ once? how can set method such accepts 3 post parameters body of request?

you can use model. defaultmodelbinder bind values form model.

enter image description here

enter image description here

public class commentviewmodel {     public string comment { get; set; }     public string email { get; set; }     public string actid { get; set; } }  public ihttpactionresult postcomment([frombody]commentviewmodel model) {     string status = ...;     return ok(status); } 

Comments