c# - Difference in parsing [FromBody] param between MVC project and Web API project -


one of co-workers tapped me earlier him odd behavior seeing web api controller function. method looks this.

// api/cart?channel=123&qsaid=456 public void post(string channel, string qsaid, [frombody]cartdto posteddata) {     string message = string.empty;     if (posteddata == null)     {         message = string.format("post data missing");         throw new httpresponseexception(request.createerrorresponse(httpstatuscode.badrequest, message));     } } 

in event, "posteddata" parameter coming null (we wrote exception in mess it). simple class string properties passed in json via post body. there number of questions on subject on , elsewhere, various resolutions, none seemed working.

i grabbed copy of project , saw myself behavior, , tried of above suggested resolutions no effect. noticed he'd stood project mvc 4 project , had made web api controller part of (though project going services, no front end).

troubleshooting, created own project starting blank asp.net web application , checked box include web api components - pasted controller project , changed namespace, along definition of complex object.

changed fiddler2 endpoint point new project - , worked. object coming through correctly , properties assigned.

i have no explanation other project created mvc4 vs blank web application web api components. question - there functional difference in how these project types handle controller parameters (specifically complex types body of post) - or else screwing somehow shed in changing project type?


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -