001
001

Reputation: 65147

Get Querystring from HTTP POST?

This code seems to be getting the querystring from a HTTP Get...

HttpContext.Current.Request.QueryString.ToString();

How do I get the querystring from a HTTP POST?

Upvotes: 4

Views: 13743

Answers (3)

Matthew Whited
Matthew Whited

Reputation: 22443

You probably want Request.Form for your form data. Request.QueryString will always be the querystring (stuff after the question mark in the URL).

Upvotes: 2

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

The code works for all HTTP verbs.

Upvotes: 0

RPM1984
RPM1984

Reputation: 73112

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.

Upvotes: 16

Related Questions