I am facing this error sometimes while I am trying to connect to the server using WebClient.
However I have gone through the previous questions and answers such as Getting EOF exception over https call about this. I have already tried their solutions but that didn't help me.
As per previous questions, I've also updated .net framework from 4.5 to 4.6.1 but still facing the same.
My code is like below
private static string GetWebContent(string url)
{
string response = null;
try
{
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
using (var request = new GZipWebClient())
{
response = request.DownloadString(url);
request.Dispose();
}
}
catch (Exception ex)
{
throw ex;
}
return response;
}
答案 0 :(得分:0)
您的代码以某种方式尝试使用TLS,但是您向其发送请求的服务器不支持它。
您可以尝试显式设置SSL3
更改:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
收件人:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;