/// <summary> /// 获取链接 /// </summary> /// <param name="name">链接名</param> /// <param name="value">链接当前值,该值可为<see cref="string.Empty"/></param> public string GetLink(string name, string value) { string result; if (!dict.TryGetValue(name, out result)) { result = LinkQuery.GetRmoveLink(this.query, name); dict.Add(name, result); } if (!string.IsNullOrEmpty(value)) { value = this.server.UrlEncode(value); } if (string.IsNullOrEmpty(result)) { return(string.Format("?{0}={1}", name, value)); } return(result + string.Format("&{0}={1}", name, value)); }
/// <summary> /// 获取链接 /// </summary> /// <param name="name">查询名</param> /// <param name="value">查询当前值,该值可为<see cref="string.Empty"/></param> /// <param name="removes">要移除的一组查询名</param> public string GetLink(string name, string value, params string[] removes) { NameValueCollection query = new NameValueCollection(this.query); foreach (string n in removes) { query.Remove(n); } string result = LinkQuery.GetRmoveLink(query, name); if (!string.IsNullOrEmpty(value)) { value = this.server.UrlEncode(value); } if (string.IsNullOrEmpty(result)) { return(string.Format("?{0}={1}", name, value)); } return(result + string.Format("&{0}={1}", name, value)); }
/// <summary> /// 获取指定请求中所有请求串 /// </summary> /// <param name="request">请求对象</param> /// <param name="remove">要排除的项</param> public static string GetRmoveLink(HttpRequest request, string remove) { return(LinkQuery.GetRmoveLink(request.QueryString, remove)); }