asp.net web api - How do I bind querystring parameters to an object with different property names? -
i have controller action following signature. add more parameters becoming more difficult manage i'm looking using single request object.
public async task<ihttpactionresult> getsearchresults( [fromuri(name = "p1")] string p1longname = null, [fromuri(name = "p2")] list<string> p2longname = null, [fromuri(name = "p3")] int? p3longname = null) {} public async task<ihttpactionresult> getsearchresults([fromuri]searchrequest parameters)
the problem, how should handle different parameters names, querystring parameter vs object property? tried adding attribute [datamember(name = "p1")]
p1longname
property of class didn't work. use request object resulting parameter binding , then, in action method, map class real property names seems add layer of unnecessary complexity.
how request object bind querystring parameters using different names?
wiki
Comments
Post a Comment