CAN SOMEBODY PLEASEEEEEE...
-
How can I request a web page using POST while passing some variables? Like I want to access http://www.localhost.com/info.aspx with POST and with variables info=0 and set=1 ? I have tried stupid HttpWebRequest BUT it is NOT WORKING :((... I posted the question few days back BUT nobody answered it... GURU PPL where ARE YOU??? me doing this..
string lcUrl = "http://localhost/test.php"; HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl); string lcPostData = "info=" + System.Web.HttpUtility.UrlEncode("0") + "&set=" + System.Web.HttpUtility.UrlEncode("1"); loHttp.Method="POST"; byte [] lbPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData); loHttp.ContentLength = lbPostBuffer.Length; Stream loPostData = loHttp.GetRequestStream(); loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length); loPostData.Flush(); loPostData.Close(); HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse(); System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252); StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc); string lcHtml = loResponseStream.ReadToEnd(); Console.Write(lcHtml); loWebResponse.Close(); loResponseStream.Close();
--------------------- A gasp of breath, A sudden death: The tale begun. A rustled page Passes an age: The tale is done. -
How can I request a web page using POST while passing some variables? Like I want to access http://www.localhost.com/info.aspx with POST and with variables info=0 and set=1 ? I have tried stupid HttpWebRequest BUT it is NOT WORKING :((... I posted the question few days back BUT nobody answered it... GURU PPL where ARE YOU??? me doing this..
string lcUrl = "http://localhost/test.php"; HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl); string lcPostData = "info=" + System.Web.HttpUtility.UrlEncode("0") + "&set=" + System.Web.HttpUtility.UrlEncode("1"); loHttp.Method="POST"; byte [] lbPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData); loHttp.ContentLength = lbPostBuffer.Length; Stream loPostData = loHttp.GetRequestStream(); loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length); loPostData.Flush(); loPostData.Close(); HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse(); System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252); StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc); string lcHtml = loResponseStream.ReadToEnd(); Console.Write(lcHtml); loWebResponse.Close(); loResponseStream.Close();
--------------------- A gasp of breath, A sudden death: The tale begun. A rustled page Passes an age: The tale is done.Hmmm... Strange. This looks nothing like mine did... ;P Well, this worked for me:
Encoding enc = Encoding.GetEncoding("ISO-8859-1");
WebClient wc = new WebClient();
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
string request = "input_name=the_value";
byte[] requestBytes = enc.GetBytes(request);
byte[] responseArray = wc.UploadData(uriString, "POST", requestBytes);string responseString = enc.GetString(responseArray);
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
-
Hmmm... Strange. This looks nothing like mine did... ;P Well, this worked for me:
Encoding enc = Encoding.GetEncoding("ISO-8859-1");
WebClient wc = new WebClient();
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
string request = "input_name=the_value";
byte[] requestBytes = enc.GetBytes(request);
byte[] responseArray = wc.UploadData(uriString, "POST", requestBytes);string responseString = enc.GetString(responseArray);
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
ahhh... you don know what you have just done! Gave me life... YES...Thank you very much... a thousand :rose: for you; to fill your room with fregrence... mE --------------------- A gasp of breath, A sudden death: The tale begun. A rustled page Passes an age: The tale is done.
-
Hmmm... Strange. This looks nothing like mine did... ;P Well, this worked for me:
Encoding enc = Encoding.GetEncoding("ISO-8859-1");
WebClient wc = new WebClient();
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
string request = "input_name=the_value";
byte[] requestBytes = enc.GetBytes(request);
byte[] responseArray = wc.UploadData(uriString, "POST", requestBytes);string responseString = enc.GetString(responseArray);
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.