Advertisement
Guest User

Untitled

a guest
Aug 5th, 2018
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. string param = "username=kerimemre@yahoo.com&password=123456";
  2. string url = "http://176.53.10.219:8089/login";
  3. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  4. request.Method = "POST";
  5. request.ContentLength = param.Length;
  6. request.ContentType = "application/x-www-form-urlencoded";
  7. request.CookieContainer = new CookieContainer();
  8.  
  9. using (Stream stream = request.GetRequestStream())
  10. {
  11. byte[] paramAsBytes = Encoding.Default.GetBytes(param);
  12. stream.Write(paramAsBytes, 0, paramAsBytes.Count());
  13. }
  14.  
  15. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  16. {
  17. MessageBox.Show(response.ToString());
  18. MessageBox.Show(response.Cookies.ToString());
  19. foreach (var cookie in response.Cookies)
  20. {
  21. var properties = cookie.GetType()
  22. .GetProperties()
  23. .Select(p => new
  24. {
  25. Name = p.Name,
  26. Value = p.GetValue(cookie)
  27. });
  28.  
  29.  
  30. foreach (var property in properties)
  31. {
  32. MessageBox.Show(property.Value.ToString());
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement