In ASP.NET MVC , one can access the form post data:
var thisData = Request.Form["this.data"];
Is it possible to achieve the same functionality in a Web API ApiController?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ASP.NET Web API has become significantly more robust in dealing with different HTTP scenarios – especially streaming. As such only media type formatters normally touch the content and have to make a coherence of the content.
In ASP.NET MVC,
application/x-www-form-urlencodedcontent type is a first class citizen (and treated especially since this is the content type of 95% of the POST requests) and we have theFormsCollectionto provide dictionary access in access, whenever it is defined as an input parameter.In ASP.NET Web API,
application/x-www-form-urlencodedis yet another content type, and supposed to be read by its MediaTypeFormatter. As such ASP.NET Web API cannot make any assumption about theForms.The normal approach in ASP.NET Web API is to represent the form as a model so the media type formatter deserializes it. Alternative is to define the actions’s parameter as
NameValueCollection: