If you choose for whatever reason not to use modelbinding in a HttpPost request, what other ways are there to access the QueryString (HttpGet) or Form parameters (HttpPost)?
Traditionally you could do:
Request.QueryString["Key"]
Request.Form["Key"]
Request["Key"]
I can't seem to find anything similiar in Web API.
For query string parameters you can use GetQueryNameValuePairs
on a HttpRequestMessage
(it's an extension method).
For form data, you need to define the action as this and the raw form data (pre-parameter binding) will be passed to you:
public void Post(NameValueCollection formData)
{
var value = formData["key"];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With