public static JsonMessage Process(HttpRequestModel model) { JsonMessage slt = new JsonMessage() { Flag = false }; if (model == null) { slt.Message = "参数错误"; return(slt); } if (string.IsNullOrEmpty(model.Url)) { slt.Message = "请填写网址"; return(slt); } if (string.IsNullOrEmpty(model.Method)) { slt.Message = "请不要篡改请求方式"; return(slt); } model.Url = model.Url.ToLower(); if (!model.Url.StartsWith("http://")) { model.Url = "http://" + model.Url; } if (!string.IsNullOrEmpty(model.Params)) { if (model.Params.StartsWith("?")) { model.Params = model.Params.Replace("?", ""); } if (model.Method == "get") { if (model.Url.IndexOf("?") > 0) { model.Url = model.Url + "&" + model.Params; } else { model.Url = model.Url + "?" + model.Params; } } } try { switch (model.Method) { case "get": slt.Flag = true; slt.Data = RequestUtility.HttpGet(model.Url); break; case "post": slt.Flag = true; Stream queryStream = RequestUtility.GetQueryStream(model.Params); slt.Data = RequestUtility.HttpPost(model.Url, null, queryStream); break; } } catch (Exception ex) { slt.Flag = false; slt.Message = ex.Message; } return(slt); }