Get Querystring from HTTP POST?
This code seems to be getting the querystr开发者_如何学Going from a HTTP Get...
HttpContext.Current.Request.QueryString.ToString();
How do I get the querystring from a HTTP POST?
The same way.
HttpContext.Current.Request.QueryString["somekey"]
Both GET and POST have querystring in the Request. Only POST has the form data.
You shouldn't be doing QueryString.ToString()
. That will evaluate ALL the keys in the NameValueCollection. You should be using the indexer to retrieve the key you want, or enumerating with the Keys property.
You probably want Request.Form
for your form data. Request.QueryString
will always be the querystring (stuff after the question mark in the URL).
The code works for all HTTP verbs.
精彩评论