#region 在url后加一个参数
        public static string AddUrlParam(string key, string value)
        {
            var dd = System.Web.HttpContext.Current.Request.QueryString;
            Dictionary<string, string> dic = new Dictionary<string, string>();
            foreach (string key2 in dd.AllKeys)
            {
                foreach (string value2 in dd.GetValues(key2))
                {
                    dic.Add(key2, value2);
                }
            }
            if (dic.ContainsKey(key))
                dic[key] = value;
            else
            {
                dic.Add(key, value);
            }
            List<string> list = new List<string>();
            foreach (var item in dic)
            {
                list.Add(string.Format("{0}={1}", item.Key, item.Value));
            }
            var query = string.Join("&", list);
            return query;
        }
        #endregion

如果要添加的参数已存在,则替换.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案