private string GetPostString() { if (Request.ContentType.ToLower().Contains("multipart/form-data")) { string sp = "--" + Regex.Match(Request.ContentType, @"boundary=(.*)").Groups[1].Value; StringBuilder sb = new StringBuilder(); IEnumerator <KeyValuePair <string, string> > dem = this.PostParameters.GetEnumerator(); while (dem.MoveNext()) { string name = dem.Current.Key; string value = dem.Current.Value; // 忽略参数名或参数值为空的参数 if (!string.IsNullOrEmpty(name)) { sb.AppendLine(sp); sb.AppendLine(string.Format(@"Content-Disposition: form-data; name=""{0}""", name)); sb.AppendLine(""); sb.AppendLine(value); } } sb.AppendLine(sp + "--"); return(sb.ToString()); } return(WebUtils.BuildPostData(PostParameters, Encode, IsUpper)); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(url)) { sb.AppendLine(url); sb.AppendLine(); } if (GetParameters != null) { sb.AppendLine(WebUtils.BuildPostData(GetParameters, Encode)); sb.AppendLine(); } if (PostParameters != null) { sb.AppendLine(); sb.AppendLine(WebUtils.BuildPostData(PostParameters, Encode)); sb.AppendLine(); } if (!string.IsNullOrEmpty(Html)) { sb.AppendLine(Html); } return(sb.ToString()); }
private String GetUrl() { if (GetParameters != null && GetParameters.Count > 0) { if (url.Contains("?")) { url = url + "&" + WebUtils.BuildPostData(GetParameters, Encode); } else { url = url + "?" + WebUtils.BuildPostData(GetParameters, Encode); } } if (url.EndsWith("?")) { url = url.TrimEnd('?'); } return(url); }