我可以手动访问 URL,但使用 .Net 时会超时。
我创建了一个按钮来更轻松地复制场景。有时我会收到一个异常,说任务被取消,否则会出现以下代码片段的 504 错误:
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
var url = "http://api.dailyfive.tv/index.php?task=REQUEST_REGIONS&session=TestWin8&app=4&model=TestWin8&ver=1.0.0.7&os=8®ion=";
var output = await ReadHttpResponse(url);
}
private async Task<string> ReadHttpResponse(string url)
{
try
{
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync(url);
return await response.Content.ReadAsStringAsync();
}
}
catch (Exception ex)
{
}
return null;
}
结果如下:
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx/1.2.0</center>
</body>
</html>