/// <summary> /// HTTP POST请求(HTTP异常仍然返回Response信息) /// </summary> /// <param name="url">请求地址</param> /// <param name="parameters">请求文本参数</param> /// <param name="charset">字符集</param> /// <param name="timeout">超时时间</param> /// <param name="cookie">Cookies</param> /// <returns>HTTP响应</returns> public static string DoPostGetResponse(string url, string parameters, string charset = "utf-8", int timeout = 20000, CookieContainer cookie = null) { HttpWebResponse webResponse = null; try { webResponse = (HttpWebResponse)HttpUtil.GetWebRequest(url, "POST", null, "", charset, timeout, cookie) .GetRequestStream(charset, parameters).GetResponse(); return(webResponse.GetResponseAsString(Encoding.GetEncoding(charset))); } catch (WebException) { return(webResponse.GetResponseAsString(Encoding.GetEncoding(charset))); } catch (Exception ex) { return($"网络错误:{ex.Message}_{ex.StackTrace}"); } }
private string GetServiceTicketUrl(HttpWebResponse signInResponse) { var content = signInResponse.GetResponseAsString(); return(ParseServiceTicketUrl(content)); }