使用WebClient 发送https请求
使用WebClient发送请求时,并且是以https协议;
WebClient webClient = new WebClient();
string result = webClient.DownloadString(url);
error : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
只需一行代码:
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };//获取或设置用于验证服务器证书的回调。[SSL]
每个问题都有解决之法,遇到问题不要怕,解决问题才是提升最快的。
--------------------------------送给每天和bug打交道的博友们