public void Register(string email, string name, string hash)
{
string registerData = "{\"email\":\"" + email + "\",\"name\":\"" + name + "\",\"hash\":\"" + hash + "\"}";
WebClient webClient = new WebClient();
webClient.Headers["Content-Type"] = "application/json";
webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(HandleRegisterAsyncResult);
webClient.UploadStringAsync(new Uri(registerUrl), registerData);
}
void HandleRegisterAsyncResult(object sender, UploadStringCompletedEventArgs e)
{
}
我基本上试图使用带有数据字符串的https:// post命令来调用web服务。它运行良好,除非我收到错误,我似乎无法找到实际的WebResponse内容。如果我转换返回给WebException的e.Error,那么有一个名为Response的类,它是一个BrowserHttpWebResponse,但是ContentLength是0(尽管我可以看到fiddler中的内容长度不是0)
有没有办法通过此方法获取响应内容?如果没有,还有另一种方法可以做一个允许我获取响应内容的Post命令吗?