Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. HttpWebRequest http = (HttpWebRequest)WebRequest.Create("URL");
  2.  
  3. string cookie = string.Empty;
  4. string values = "vb_login_username=" + username + "&vb_login_password=" + password + "securitytoken=guest&" + "cookieuser=checked&" + "do=login";
  5.  
  6. http.Method = "POST";
  7. http.ContentType = "application/x-www-form-urlencoded";
  8. http.ContentLength = values.Length;
  9.  
  10. CookieContainer cookies = new CookieContainer();
  11. http.CookieContainer = cookies;
  12.  
  13. ServicePointManager.Expect100Continue = false;
  14.  
  15.  
  16. using (var stream = new StreamWriter(http.GetRequestStream(), Encoding.ASCII))
  17. {
  18. stream.Write(values);
  19. }
  20.  
  21.  
  22.  
  23. HttpWebResponse response = (HttpWebResponse)http.GetResponse();
  24.  
  25. foreach (var c in response.Cookies)
  26. {
  27. cookie = cookie + c.ToString() + ";";
  28. }
  29.  
  30. return cookie;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement