HttpWebRequest hwr;
hwr = (HttpWebRequest)WebRequest.Create(url);
hwr.Method = "POST";
string postdata = "formpostdata=" + System.Web.HttpUtility.UrlEncode(dataToPost);
ASCIIEncoding enc = new ASCIIEncoding();
byte[] bytel = enc.GetBytes(postdata);
hwr.ContentType = "application/x-www-form-urlencoded";
hwr.ContentLength = bytel.Length;
//write to request stream
Stream newstream = hwr.GetRequestStream();
newstream.Write(bytel, 0, bytel.Length);
newstream.Close();
hwr.Timeout = 10000;
//get response
HttpWebResponse hwresp = (HttpWebResponse)hwr.GetResponse();
Stream st = hwresp.GetResponseStream();
No comments:
Post a Comment