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