C#WebClient下载字符串https

在webbrowser中,我通常可以加载以下URL: https://security.ultimatxxxx.com:443/Serverstatus.ashx ://security.ultimatxxxx.com:443 / https://security.ultimatxxxx.com:443/Serverstatus.ashx

当我这样做时:

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

出于测试目的,您可以调用: ultimate-eur而不是ultimatxxxx

它不起作用,但是当我加载没有https的普通URL时我没有问题。 我必须添加哪个参数,以便Webclient也可以下载字符串?

我想在Monotouch中使用该function,但语言是C#。

如果您只想接受所有证书,则在提出请求之前,您需要设置证书检查:

 ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 

这将接受所有证书。

虽然 – 如果您需要实际检查证书,请执行以下操作:

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

一个可能的原因可能是某些网站向不同的浏览器提供不同的结果。

您可以尝试提供浏览器信息以假装呼叫来自浏览器。

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

要么

你还没有绑定Aysnc调用的Aysnc