DownloadString gives a timeout on a https url seeming to work in a browser

c#, https, json, webclient

Solution

Just set `HttpRequestHeader.Accept` and `HttpRequestHeader.UserAgent` headers. This works

using (WebClient client = new WebClient())
{
    client.Headers[HttpRequestHeader.Accept] = "text/html, image/png, image/jpeg, image/gif, */*;q=0.1";
    client.Headers[HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12";
    string s = client.DownloadString(ApiLnk);
    int i = 0;
}

Problem

I am trying to get the content from this URL into my program: https://data.mtgox.com/api/2/BTCUSD/money/ticker . When visiting the URL in any of my browsers, it works perfectly. However in my program, it waits for 90 seconds, and give me a timeout. This is my code: ``` private const string ApiLnk = "https://data.mtgox.com/api/2/BTCUSD/money/ticker"; static void Main(string[] args) { using (WebClient client = new WebClient()) { string s = client.DownloadString(ApiLnk); int i = 0; } } ``` The string s never gets assigned, as the client.DownloadString() is the one stalling. When getting a normal URL like Google.com, it works perfectly. Any idea what's wrong?

Original source