The underlying connection was closed: An unexpected error occurred on a receive

解决方法

webRequest.KeepAlive = false;
ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;

 //WebRequest请求被中止: 未能创建 SSL/TLS 安全通道  在请求之前插入TLS安全协议:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

原文地址:https://www.cnblogs.com/suizhikuo/p/11331298.html