private void btnTestRequest_Click(object sender, EventArgs e) { string result = string.Empty; string uri = AppRuntimes.Instance.Url + "Test/GetListText1?" + "parma1=" + 1 + "&parma2=" + 2; var users = new List <User>() { new User() { Phone = "13800138000", Name = "xialei" }, new User() { Phone = "13800138000", Name = "zhangsanfeng" }, }; string requestBody = JsonUitl.ToJson(users); result = HttpRequest.Instance.PostRequestComplex(uri, requestBody); uri = AppRuntimes.Instance.Url + "Test/GetZip"; string dirPath = Path.Combine(AppRuntimes.Instance.RootPath, "Image"); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } var fileFullPath = Path.Combine(dirPath, "PadImage.zip"); if (!File.Exists(fileFullPath)) { File.Create(fileFullPath).Close(); } var downFlag = HttpRequest.Instance.DownloadFile(uri, fileFullPath); }
public ActionResult GetListText(List <User> users) { string msg = string.Empty; string text = string.Empty; if (users == null) { //验证 //foreach (var user in users) //{ // foreach (var item in user.GetRuleViolations()) // { // if (string.IsNullOrEmpty(item.ToString())) // { // msg = item.ToString(); // goto lbl; // } // } //} text = JsonUitl.ToJson(new { Code = 500, Msg = msg }); } else { users = new List <User>() { new User() { Phone = "13800138000", Name = "xialei" }, new User() { Phone = "13800138000", Name = "zhangsanfeng" }, }; text = JsonUitl.ToJson(users); } // lbl: return(Content(text, "text/plain", System.Text.Encoding.Default)); }