I know this has been asked before but the solutions suggested in those cases have not work for me. I have a simple console app that scrapes data from a website. Last night they updated their security settings so my code doesn't work anymore.
Here Is the code snippet I'm trying to use:
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
var request2 = WebRequest.Create("https://www.eex-transparency.com/") as HttpWebRequest;
request2.Method = "GET";
request2.Accept = "text/html, application/xhtml+xml, */*";
request2.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-gb");
request2.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request2.Headers.Add("DNT", "1");
request2.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko";
request2.Host = "www.eex-transparency.com";
request2.KeepAlive = true;
request2.Headers.Set(HttpRequestHeader.CacheControl, "no-cache");
request2.Proxy = ProxyFactory.GetWebProxy();
using (var response = request2.GetResponse())
{}
}
catch (Exception ex)
{ Console.WriteLine(ex);}
There error I receive is:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed becausethe remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocol Request asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, A syncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
Any help will be greatly appreciated.
Thanks in advance.