HttpWebResponse超时

时间:2017-02-22 19:13:21

标签: c# .net web

我在下面的代码上遇到超时异常。只有这个网站有问题。有什么问题?

string ackoURL = "https://www.zomato.com/sk/brno/u-heligonky-z%C3%A1brdovice-brno-st%C5%99ed/denn%C3%A9-menu";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ackoURL);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
  //this code is never executed
}

我尝试修改SecurityProtocol,KeepAlive和simmilar的东西。没有成功。

1 个答案:

答案 0 :(得分:3)

等待这些标题

enter image description here

..并且它有效

Uri u = new Uri("https://www.zomato.com/sk/brno/u-heligonky-z%C3%A1brdovice-brno-st%C5%99ed/denn%C3%A9-menu");
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(u);
        request.AutomaticDecompression = DecompressionMethods.GZip;
        request.Headers.Add("Accept-Language", "en-gb,en;q=0.5");
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            using(Stream stream = response.GetResponseStream())
            {
                using(StreamReader reader= new StreamReader(stream))
                {
                    var result = reader.ReadToEnd();

                }
            }
        }