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

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();
}

学习技术最好的文档就是官方文档,没有之一。
还有学习资料Microsoft LearnCSharp LearnMy Note
如果,你认为阅读这篇博客让你有些收获,不妨点击一下右下角的推荐按钮。
如果,你希望更容易地发现我的新博客,不妨点击一下关注

原文地址:https://www.cnblogs.com/Lulus/p/14280404.html