url 请求的路径地址 postData 传入的参数
public static string Post(string url, string postData) { CookieContainer cookieContainer = new CookieContainer(); Uri URI = new Uri(url); byte[] byteArr = Encoding.UTF8.GetBytes(postData); HttpWebRequest request = WebRequest.Create(URI) as HttpWebRequest; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.CookieContainer = cookieContainer; request.ContentLength = byteArr.Length; Stream st = request.GetRequestStream(); st.Write(byteArr, 0, byteArr.Length); st.Close(); WebResponse response = request.GetResponse() as WebResponse; System.IO.Stream responseStream = response.GetResponseStream(); System.IO.StreamReader reader = new System.IO.StreamReader(responseStream, Encoding.UTF8); string srcString = reader.ReadLine(); responseStream.Dispose(); reader.Dispose(); return srcString; }