Example #1
0
 /// <summary>
 /// 发起Post请求
 /// </summary>
 /// <typeparam name="T">返回数据类型(Json对应的实体)</typeparam>
 /// <param name="url">请求Url</param>
 /// <param name="cookieContainer">CookieContainer,如果不需要则设为null</param>
 /// <param name="encoding"></param>
 /// <param name="timeOut">代理请求超时时间(毫秒)</param>
 /// <param name="fileDictionary"></param>
 /// <param name="postDataDictionary"></param>
 /// <returns></returns>
 public static string PostFileGetJson(string url, CookieContainer cookieContainer = null, Dictionary<string, string> fileDictionary = null, Dictionary<string, string> postDataDictionary = null, Encoding encoding = null, int timeOut = 10000)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         postDataDictionary.FillFormDataStream(ms); //填充formData
         string returnText = HttpPost(url, cookieContainer, ms, fileDictionary, null, encoding, timeOut: timeOut);
         return returnText;
     }
 }
Example #2
0
 /// <summary>
 /// 使用Post方法获取字符串结果,常规提交
 /// </summary>
 /// <returns></returns>
 public static string HttpPost(string url, CookieContainer cookieContainer = null, Dictionary<string, string> formData = null, Encoding encoding = null, int timeOut = App.AppRequestTimeOut)
 {
     MemoryStream ms = new MemoryStream();
     formData.FillFormDataStream(ms);//填充formData
     return HttpPost(url, cookieContainer, ms, null, null, encoding, timeOut);
 }
Example #3
0
 /// <summary>
 /// 使用Post方法获取字符串结果,常规提交
 /// </summary>
 /// <returns></returns>
 public static string HttpPost(string url, CookieContainer cookieContainer = null, Dictionary<string, string> formData = null, Encoding encoding = null,  X509Certificate cer = null,int timeOut = Config.TIME_OUT)
 {
     MemoryStream ms = new MemoryStream();
     formData.FillFormDataStream(ms);//填充formData
     return HttpPost(url, cookieContainer, ms, null, null, encoding,cer, timeOut);
 }