c# - WebApi binding a single parameter from body (form-urlencoded) -
i understand why in case when there 1 parameter in post body, content type url-formencoded syntax different in case of multiple parameters.
let's assume we've got these 2 methods matching route templates:
public string postsinglestring([frombody]string value) { return value; } public class values { public string value1 {get; set;} public string value2 {get; set;} } public string postmultiplestrings(values values) { return string.format("{0}-{1}", values.value1, values.value2); }
in first case request be:
post [controller]/ body: =myvalue
in second 1 though:
post [controller]/ body: value1=one&value2=two
if in first case syntax second example used (value=myvalue
) param won't bind (unless string wrapped in complex type).
can explain why case?
Comments
Post a Comment