首页 > 编程语言 >C#:https文件下载

C#:https文件下载

时间:2022-12-29 17:33:07浏览次数:44  
标签:C# ServicePointManager 下载 https SecurityProtocol WebClient Tls12

今天在.net4.5环境下用WebClient下载https的文件时,报错: 基础连接已经关闭: 发送时发生错误。

加上ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;后正常。

using (WebClient client = new WebClient())
{
  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  client.DownloadFile(url, fullName);
}

 先记录一下;以后遇到再加上其他情况。

 

标签:C#,ServicePointManager,下载,https,SecurityProtocol,WebClient,Tls12
From: https://www.cnblogs.com/yellow3gold/p/17013082.html

相关文章