看哪,code:
using (var client = new WebClient())
{
using (var stream = client.OpenWrite("http://localhost/", "POST"))
{
stream.Write(post, 0, post.Length);
}
}
现在,我怎么读取HTTP输出?
Now, how do I read the HTTP output?
它看起来像你有一个字节[]
数据的发布;在这种情况下,我想你会发现它更容易使用:
It looks like you have a byte[]
of data to post; in which case I expect you'll find it easier to use:
byte[] response = client.UploadData(address, post);
如果响应是文字,是这样的:
And if the response is text, something like:
string s = client.Encoding.GetString(response);
(或您选择编码
的 - 也许 Encoding.UTF8
)