Amit Raz
Amit Raz

Reputation: 5536

Using WebClient.DownloadString()

I have a strange problem when usinng WebClient.DownloadString(). It is very very slow and sometimes does not work but if I try browsing using IE9/Chrome to the website everything works fine.

Here is the code:

        var req = new WebClient();
        req.Encoding = Encoding.UTF8;
        string result = string.Empty;
        result = req.DownloadString(someURL);

Any ideas?

Upvotes: 0

Views: 6601

Answers (2)

Damith
Damith

Reputation: 63065

Try Setting WebClient.Proxy to GlobalProxySelection.GetEmptyWebProxy

Upvotes: 0

Felice Pollano
Felice Pollano

Reputation: 33252

The snippet you sent is correct ( a part the string result = string.Empty; that is absolutely pointless). If you feel the application blocking you should consider using DownloadStringAsync.

Upvotes: 1

Related Questions