1 public static string HttpPost(string url, byte[] postData) 2 { 3 HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; 4 request.Method = "post"; 5 request.ContentType = "application/x-www-form-urlencoded"; 6 request.ContentLength = postData.Length; 7 request.CookieContainer = new CookieContainer();//页面跳转是携带cookie信息 8 Stream requestStream = request.GetRequestStream(); 9 requestStream.Write(postData, 0, postData.Length); 10 requestStream.Close(); 11 HttpWebResponse respone = (HttpWebResponse)request.GetResponse(); 12 StreamReader read = new StreamReader(respone.GetResponseStream(), Encoding.GetEncoding("utf-8")); 13 string result = read.ReadToEnd(); 14 return result; 15 }