Hi, so i build this class where you can login to mybb 1.6, it was easy since it had no redirects, but now it's pretty hard to access and download the html source of the usercp.php page, since once i log in and get redirected in c# code, i get the source html of when you're not logged in, with the error and the login form all over again. This is my Class:
Anyone can help ?
public string MakePostRequest(string url = "www.website.com/usercp.php", string postData = "username=" + Username + "&password=" + Password + "&remember=yes&submit=Login&action=do_login&url=" + ForumURL + "member.php?action=login")
{
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
request.CookieContainer = cookieMoster;
request.UserAgent = UserAgent;
request.KeepAlive = true;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.AllowAutoRedirect = true;
byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(postData);
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes,0,postBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string sReturn = sr.ReadToEnd();
sr.Dispose();
return sReturn;
}
Anyone can help ?