HttpWebRequest method POST

  • Thread starter Thread starter PawelR
  • Start date Start date
P

PawelR

Hello Group,

How send few value using HttpWebReguest with POST method in one request?

Thx.
PawelR
 
PawelR wrote:

How send few value using HttpWebReguest with POST method in one request?

What kind of "values", what kind of Content-Type should the request body
have?

If you simply want to POST some name=value pairs as
application/x-www-form-urlencoded contents then it might be easier to
use WebClient and its UploadValues method:
<http://msdn.microsoft.com/library/d...fSystemNetWebClientClassUploadValuesTopic.asp>

If you want to do that with HttpWebRequest then get hold of the request
stream, construct the request body (i.e. name=value pairs encoded as
application/x-www-form-urlencoded) and write it to the request stream.
To urlencode the name and values you can use UrlEncode method of
HttpUtitity.
 
Thanks,
I ought to send to server few pairs: name1=value1, name2=value2,
name3=value3 and I must use http post because server working only with http
post method.
Pawel
 
PawelR said:
Thanks,
I ought to send to server few pairs: name1=value1, name2=value2,
name3=value3 and I must use http post because server working only
with http post method. Pawel

That's what WebClient.UploadValues() will do.

Cheers,
 
Back
Top