今天在.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