C # WebClient Download String https

In a web browser, I can normally load the following URL: https://security.ultimatxxxx.com:443/Serverstatus.ashx : https://security.ultimatxxxx.com:443/Serverstatus.ashx

When I do it with

 Webclient.DownloadStringAsync("https://security.ultimatxxxx.com:443/Serverstatus.ashx"); 

For testing purposes, you can call: ultimate-eur instead of ultimatxxxx .

This does not work, but when I load a regular URL without https, I have no problem. What argument should I add so that Webclient can also load a string?

I want to use this feature in Monotouch, but the language is C #.

+4
source share
2 answers

If you just want to accept all certificates, you need to install a certificate check before making your request:

 ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 

This will accept all certificates.

Although - if you really need to verify the certificate, do something like:

 ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { //to check certificate }; 
+8
source

One possible reason may be that some websites provide different results for different browsers.

You can try to provide browser information to pretend the call is from a browser.

 var client = new WebClient(); client.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15"; string download = client.DownloadString("https://security.ultimatxxxx.com:443/Serverstatus.ashx"); 

Or

You do not bind the completedEvent call to Aysnc .

+2
source

All Articles