Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. WebRequest req = WebRequest.Create(formUrl.Trim());
  2.  
  3. public void LoginToUrl(string url,string username, string password )
  4. {
  5. formUrl = url;
  6. formParams = string.Format("username={0}&password={1}", username,password);
  7.  
  8. WebRequest req = WebRequest.Create(formUrl.Trim());//
  9. req.ContentType = "application/x-www-form-urlencoded";
  10. req.Method = "POST";
  11. bytes = Encoding.ASCII.GetBytes(formParams);
  12. req.ContentLength = bytes.Length;
  13. using (Stream os = req.GetRequestStream())
  14. {
  15. os.Write(bytes, 0, bytes.Length);
  16. }
  17. WebResponse resp = req.GetResponse();
  18. cookieHeader = resp.Headers["Set-cookie"];
  19. }
  20.  
  21. Host=internetlogin1.cu.edu.ng
  22.  
  23. User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
  24.  
  25. Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  26.  
  27. Accept-Language=en-US,en;q=0.5
  28.  
  29. Accept-Encoding=gzip, deflate
  30.  
  31. Connection=keep-alive
  32.  
  33. Content-Type=application/x-www-form-urlencoded
  34.  
  35. Content-Length=49
  36. POSTDATA=dst=&popup=true&username=13ck015373&password=F3NB
  37.  
  38. Uri serverUri = new Uri("http://url.com/sub/somethingService");
  39. var webRequest = (HttpWebRequest)WebRequest.Create(serverUri);
  40.  
  41. var webRequest = (HttpWebRequest)WebRequest.Create("http://url.com/sub/somethingService");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement