In ASP.NET MVC , one can access the form post data:
var thisData = Request.Form[\"this.data\"];
Is it possible to achieve the
Well, it is not possible because HttpRequestMessage doesn't provide that kind of collection out of the box.
However, if your application is hosted under ASP.NET, you can get to the current HttpContext object and get the form values from there:
public class CarsController : ApiController {
public string[] Get() {
var httpContext = (HttpContextWrapper)Request.Properties["MS_HttpContext"];
var foo = httpContext.Request.Form["Foo"];
return new string[] {
"Car 1",
"Car 2",
"Car 3"
};
}
}
But I am not sure if this is the best way of doing this kind of stuff.