2017-02-22 45 views
1

我收到代碼下面的超時異常。只有這個網站是有問題的。問題是什麼?HttpWebResponse超時

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和類似的東西。沒有成功。

回答

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(); 

       } 
      } 
     }