asp.net web api - web api FromUri and FromBody attributes misunderstanding -
i found example in google:
public string getvalue([fromuri]book b, [fromuri]author a) { return b.name + " ("+a.authorname+")"; } public string postvalue([frombody]person p) { return p.firstname; }
i can't understand point of [fromuri] attribute if http method send data part of url respectively, what's point of [frombody] attribute use in http post method?
thank in advance.
this article explain why [fromuri] necessary , how workaround not need write anymore.
web api try eagerly bind non-primitive , non-string covnertible types body of request. while in many cases that’s right, semantically, doesn’t make sense , head requests, since in accordance http specification, these body-less requests.
the [frombody] usei force web api read simple type request body. in sample, person complex type, attribute not necessary. worth yet, cannot use 2 parameters frombody, said here.
Comments
Post a Comment