/// <summary> /// 上传文件。formData参数附加到url /// </summary> /// <param name="formData"></param> /// <param name="filePath"></param> /// <returns></returns> public string Upload(FormData formData, string filePath) { var url = String.Format("{0}?{1}", Url, formData == null ? "" : formData.Format()); var data = new WebClient().UploadFile(url, "POST", filePath); return(Encoding.GetString(data)); }
/// <summary> /// 以POST方式提交数据。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="body"></param> /// <param name="formData"></param> /// <returns></returns> public T Post <T>(string body, FormData formData = null) { var url = String.Format("{0}{1}", Url, formData == null ? "" : string.Format("?{0}", formData.Format())); return(Post <T>(url, body)); }