标签:style blog http color os for ar div
public static string InsertOrUpdateQueryString(string[] keys, string[] values) { return InsertOrUpdateQueryString(System.Web.HttpContext.Current.Request, keys, values); } public static string InsertOrUpdateQueryString(System.Web.HttpRequest request, string[] keys, string[] values) { string keyValue; string keyCurrent; System.Text.StringBuilder pathBuilder = new System.Text.StringBuilder(request.Path); pathBuilder.Append("?"); int handedCount = 0; if (request.QueryString.HasKeys()) { for (var i = 0; i < request.QueryString.AllKeys.Length;i++ ) { keyValue = request.QueryString.AllKeys[i]; if (string.IsNullOrEmpty(keyValue)) { continue; } if (Array.IndexOf<string>(keys, keyValue) != -1) { continue; } keyCurrent = request.QueryString[i]; if (string.IsNullOrEmpty(keyValue)) { continue; } if (i != 0) { pathBuilder.AppendFormat("&{0}={1}", keyValue, keyCurrent); } else { pathBuilder.AppendFormat("{0}={1}", keyValue, keyCurrent); } handedCount++; } } for (var i = 0; i < keys.Length; i++) { keyValue = keys[i]; keyCurrent = values[i]; if (string.IsNullOrEmpty(keyValue) || string.IsNullOrEmpty(keyCurrent)) { continue; } if (handedCount++ != 0) { pathBuilder.AppendFormat("&{0}={1}", keyValue,keyCurrent); } else { pathBuilder.AppendFormat("{0}={1}", keyValue, keyCurrent); } } return pathBuilder.ToString(); }
Asp.net QueryString批量插入和更新,布布扣,bubuko.com
标签:style blog http color os for ar div
原文地址:http://www.cnblogs.com/yomho/p/3905276.html