private static string PostResponse(string url, string postData, string userAgent = null) { string str = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); ASCIIEncoding encoding = new ASCIIEncoding(); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"; if (userAgent != null) { request.UserAgent = userAgent; } using (Stream stream = request.GetRequestStream()) { byte[] bytes = Encoding.ASCII.GetBytes(postData); stream.Write(bytes, 0, bytes.Length); stream.Close(); } using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream stream2 = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream2)) { str = reader.ReadToEnd(); reader.Close(); } stream2.Close(); } response.Close(); } return str; }
FileStream
GetResponseStream
ConnectStream
GZipWrapperStream
DeflateWrapperStream
Stream.Length
NotSupportedException
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)