使用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打交道的博友们

相关文章:

  • 2021-09-10
  • 2021-07-29
  • 2021-07-09
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2021-10-22
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2021-12-19
  • 2021-06-11
相关资源
相似解决方案