HttpClient访问https的时候报错:

The request was aborted: Could not create SSL TLS secure channel.

这样修改:

var url = "https://...";
if (url.ToLower().StartsWith("https"))
{
	System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
}
using (var client = new HttpClient())
{
	var r = await client.GetAsync(url);
	var s = await r.Content.ReadAsStringAsync();
}

相关文章:

  • 2021-10-23
  • 2021-10-22
  • 2022-12-23
  • 2021-06-21
  • 2021-12-19
  • 2021-09-14
  • 2021-06-11
猜你喜欢
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-02-26
  • 2022-12-23
相关资源
相似解决方案