Windows.Web.Http.HttpClient 连续抛出错误 404
Windows.Web.Http.HttpClient throws continuously error 404
我正在尝试使用 Windows.Web.Http.HttpClient class 但它一直向我抛出 404 错误,即使我尝试了文档中的代码:
var uri = new Uri("http://example.com/datalist.aspx");
var httpClient = new HttpClient();
try
{
var result = await httpClient.GetStringAsync(uri);
Debug.WriteLine("content : {0}", result);
}
catch (Exception e)
{
Debug.WriteLine("error : {0}", e.Message);
}
这是错误:
A first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll
error : Not found (404).
Response status code does not indicate success: 404 (Not Found).
我可以使用 IE 等网络浏览器从 phone 访问该地址。
那是因为它确实 return 404
(使用嗅探器并检查)。
将 url 更改为 http://www.example.com
一切正常。
站点 return 对所有请求的响应相同。你可以试试:
http://www.example.com/mynickistuff.abcd
我正在尝试使用 Windows.Web.Http.HttpClient class 但它一直向我抛出 404 错误,即使我尝试了文档中的代码:
var uri = new Uri("http://example.com/datalist.aspx");
var httpClient = new HttpClient();
try
{
var result = await httpClient.GetStringAsync(uri);
Debug.WriteLine("content : {0}", result);
}
catch (Exception e)
{
Debug.WriteLine("error : {0}", e.Message);
}
这是错误:
A first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll
error : Not found (404).
Response status code does not indicate success: 404 (Not Found).
我可以使用 IE 等网络浏览器从 phone 访问该地址。
那是因为它确实 return 404
(使用嗅探器并检查)。
将 url 更改为 http://www.example.com
一切正常。
站点 return 对所有请求的响应相同。你可以试试:
http://www.example.com/mynickistuff.abcd