c#, http POST




You could take a look at the WebClient class. It allows you to post data to an arbitrary url:

using (var client = new WebClient()) { var dataToPost = Encoding.Default.GetBytes("param1=value1&param2=value2"); var result = client.UploadData("http://example.com", "POST", dataToPost); // do something with the result }

Will generate the following request:

POST / HTTP/1.1 Host: example.com Content-Length: 27 Expect: 100-continue Connection: Keep-Alive param1=value1&param2=value2

Leave a Reply