I need to use "HTTP Post" with WebClient to post some data to a specific URL I have.
Now, I know this can be accomplished with WebRequest but for some reasons I wanna use WebClient instead. Is that possible? If so, can someone show me some example or point me to the right direction?
I just found the solution and yea it was easier than I thought :)
so here is the solution:
it works like charm :)
Using
WebClient.UploadString
orWebClient.UploadData
you can POST data to the server easily. I’ll show an example using UploadData, since UploadString is used in the same manner as DownloadString.more : http://www.daveamenta.com/2008-05/c-webclient-usage/
There is a built in method called UploadValues that can send HTTP POST (or any kind of HTTP methods) AND handles the construction of request body (concatenating parameters with "&" and escaping characters by url encoding) in proper form data format:
can be simplified as
http://www.myurl.com/post.php?param1=value1¶m2=value2¶m3=value3.
This always works. I found the original one works on and off.