Hello.
First, sorry beause my Eng not good.
I try using ssh.net library connect and login to my website
Thanks you
First, sorry beause my Eng not good.
I try using ssh.net library connect and login to my website
using (var client = new SshClient(hostOrIP, userName, password))
{
client.Connect();
var port1 = new ForwardedPortLocal("localhost", 8081, Constants.Host, 80);
client.AddForwardedPort(port1);
port1.Start();
var request = (HttpWebRequest)WebRequest.Create("http://localhost:8081/ajax/login");
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version11;
var postData = "email=minhnd249@gmail.com";
postData += "&password=123456";
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString;
}
Then i received error: The underlying connection was closed: An unexpected error occurred on a receivePlease help me.
Thanks you