471,319 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

HttpWebRequest method POST

Hello Group,

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

Thx.
PawelR
Dec 1 '05 #1
3 7332


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/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetWebClientClassUploadValuesTopic.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.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 1 '05 #2
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
Uzytkownik "Martin Honnen" <ma*******@yahoo.de> napisal w wiadomosci
news:uJ**************@TK2MSFTNGP14.phx.gbl...


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/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetWebClientClassUploadValuesTopic.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.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Dec 1 '05 #3
PawelR wrote:
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,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Dec 1 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by TJO | last post: by
2 posts views Thread by Kueishiong Tu | last post: by
9 posts views Thread by Mike Cronin via DotNetMonster.com | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.