public static string PostData(string url, string data, string contentType) { string result = ""; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentLength = data.Length; objRequest.ContentType = contentType; using (StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream())) { myWriter.Write(data); } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); } return result; } public static string PostData(string url, string data) { return PostData(url, data, "application/x-www-form-urlencoded"); }
Friday, October 15, 2010
Post Data using HttpWebRequest
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment