Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private string login(string url, string username, string password)
- {
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
- //string cookie = "";
- string values = "vb_login_username=" + username + "&vb_login_password=" + password
- + "&securitytoken=guest&"
- + "cookieuser=checked&"
- + "do=login";
- req.Method = "POST";
- req.ContentType = "application/x-www-form-urlencoded";
- req.ContentLength = values.Length;
- req.Timeout = 10000;
- req.KeepAlive = true;
- CookieContainer a = new CookieContainer();
- req.CookieContainer = a;
- System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error
- using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
- { writer.Write(values); }
- //HttpWebResponse c = (HttpWebResponse)req.GetResponse();
- try { this.response = (HttpWebResponse)req.GetResponse(); }
- catch (WebException ex)
- {
- MessageBox.Show(ex.ToString());
- }
- foreach (Cookie cook in this.response.Cookies) { this.cookie = this.cookie + cook.ToString() + ";"; }
- return this.cookie;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement