在很多的业务需求中都可能会用到其他网站的数据..
当遇到SSL(https)加密的页面时将会报错...
我们可以用个小方法解决:
先加入下面的方法
private bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
然后只需在访问SSL(https)加密的页面时在其方法前加上如下
ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;//给它加个委托
WebResponse response = WebRequest.Create("https://").GetResponse();
好了可以正常访问SSL(https)加密的页面了
浙公网安备 33010602011771号