/// /// POST请求获取信息/// /// /// /// public string POST(string url, string paramData, int timeout = 5000, List COOKIEs = null){string ret = string.Empty;try{byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(paramData); //转化HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(url));if (url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)){ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate); //rcvc;webReq.ProtocolVersion = HttpVersion.Version10;}SetProxy(ref webReq);webReq.Method = "POST";webReq.ContentType = "application/json; charset=utf-8";webReq.ServicePoint.Expect100Continue = false;//webReq.ContentType = "text/html;charset=utf-8";webReq.Timeout = timeout;webReq.ContentLength = byteArray.Length;if (!string.IsNullOrEmpty(UserAgent))webReq.UserAgent = UserAgent;if (COOKIEs != null && COOKIEs.Count > 0){webReq.COOKIEContainer = new COOKIEContainer();string host = new Uri(url).Host;foreach (System.Net.COOKIE c in COOKIEs){c.Domain = host;webReq.COOKIEContainer.Add(c);}}Stream newStream = webReq.GetRequestStream();newStream.Write(byteArray, 0, byteArray.Length);//写入参数
newStream.Close();HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);ret = sr.ReadToEnd();sr.Close();response.Close();newStream.Close();}catch (Exception ex){ClassLoger.Error(ex, "HttpUtils/POST", url);throw ex;}return ret;}