Behold the code:
using (var client = new WebClient())
{
using (var stream = client.OpenWrite("http://localhost/", "POST"))
{
stream.Write(post, 0, post.Length);
}
}
Now, how do I read the HTTP output?
cnetwebclient
Behold the code:
using (var client = new WebClient())
{
using (var stream = client.OpenWrite("http://localhost/", "POST"))
{
stream.Write(post, 0, post.Length);
}
}
Now, how do I read the HTTP output?
Best Answer
It looks like you have a
byte[]
of data to post; in which case I expect you'll find it easier to use:And if the response is text, something like:
(or your choice of
Encoding
- perhapsEncoding.UTF8
)