I've been Googling and trying all the solutions I could find or think of myself. The site I'm trying to load is running TLS1.2 as is a few other sites I tried to test with to make sure it wasn't a TLS1.2 issue. The other sites loaded fine.
byte[] buffer = Encoding.ASCII.GetBytes(
"mod=www&ssl=1&dest=account_settings.ws"
+ "&username=" + username.Replace(" ", "20%")
+ "&password=" + password.Replace(" ", "20%"));
ServicePointManager.MaxServicePointIdleTime = 1000;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
HttpWebRequest WebReq =
(HttpWebRequest)WebRequest.Create(
"https://secure.runescape.com/m=weblogin/login.ws");
WebReq.Method = "POST";
WebReq.KeepAlive = false;
WebReq.Referer =
"https://secure.runescape.com/m=weblogin/loginform.ws"
+ "?mod=www&ssl=1&expired=0&dest=account_settings.ws";
WebReq.ContentType = "application/x-www-form-urlencoded";
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
reply = _Answer.ReadToEnd();
curAccount++;
if (reply.Contains("Login Successful"))
{
eturn true;
}
else
{
eturn false;
}
No matter what I try I keep getting the exception
The underlying connection was closed: An unexpected error occurred on a send.
Under more details I found
Authentication failed because the remote party has closed the transport stream.
Tls | Tls11 | Tls12
in most cases. – Immerse