Advertisement
marcopolorez

C####

Sep 13th, 2016
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. var request = (HttpWebRequest)WebRequest.Create("http://www.example.com/recepticle.aspx");
  2.  
  3. var postData = "thing1=hello";
  4.     postData += "&thing2=world";
  5. var data = Encoding.ASCII.GetBytes(postData);
  6.  
  7. request.Method = "POST";
  8. request.ContentType = "application/x-www-form-urlencoded";
  9. request.ContentLength = data.Length;
  10.  
  11. using (var stream = request.GetRequestStream())
  12. {
  13.     stream.Write(data, 0, data.Length);
  14. }
  15.  
  16. var response = (HttpWebResponse)request.GetResponse();
  17.  
  18. var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement