当我尝试使用Windows Phone 8.1中的HttpClient向API发布数据时,我总是会收到HRESULT:0x80072F0D
异常。在fiddler中,它可以正常工作。
try
{
var requestbody="json data"
HttpClient httpClient = new HttpClient();
HttpRequestMessage msg = new HttpRequestMessage(new HttpMethod("POST"), new Uri(addressUri));
msg.Content = new HttpStringContent(requestbody);
msg.Content.Headers.ContentType = new HttpMediaTypeHeaderValue("application/json");
HttpResponseMessage response = await httpClient.SendRequestAsync(msg).AsTask();
}
catch (Exception ex)
{
getting **Exception from HRESULT: 0x80072F0D**
}
请告诉我出了什么问题?
---FYI----
如需获取有关 HRESULT 代码的其他信息:请参阅此 WebErrorStatus 枚举。
var exceptionDetail = WebError.GetStatus(ex.GetBaseException().HResult);
if (exceptionDetail == WebErrorStatus.HostNameNotResolved)
{
//
}
HttpClient
?还有异常信息是什么? - Fred