I'm trying to login to a website through webrequest, but the webresponse is returning the same html of the login page.
CookieContainer cookies = new CookieContainer();
String postData = "vb_login_username=myusername&vb_login_password=mypassword";
byte[] send = Encoding.Default.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("domain url here"));
request.CookieContainer = cookies;
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.Timeout = 30000;
request.ContentLength = send.Length;
Stream stream = request.GetRequestStream();
stream.Write(send, 0, send.Length);
stream.Flush();
stream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
foreach (Cookie cook in response.Cookies)
{
cookies.Add(cook);
Console.WriteLine(cook.Name+ cook.Value+ cook.Path+ cook.Domain);
}
StreamReader reader = new StreamReader(response.GetResponseStream());
String result = reader.ReadToEnd();
Console.WriteLine(result);
Unfortunately, it is not so easy with this site. At first look at
<form>
tag:Before submit it calls
md5hash
function to make a hash of password. Then in POST data after trying to log in you can see thevb_login_md5password
andvb_login_md5password_utf
parameters, but simplevb_login_password
is empty.