标签:style blog color os for ar div amp
1 string InsertOrUpdateQueryStringItem(string key, string value) 2 { 3 if (Request.QueryString.HasKeys()) 4 { 5 if (!Array.Exists<string>(Request.QueryString.AllKeys, (qs) => { return qs.Equals(key); })) 6 { 7 return string.Format("{0}&{1}={2}", Request.RawUrl, key, value); 8 } 9 else 10 { 11 System.Text.StringBuilder pathBuilder = new System.Text.StringBuilder(Request.Path); 12 pathBuilder.Append("?"); 13 string keyValue; 14 string keyCurrent; 15 int handedCount = 0; 16 17 foreach (var k in Request.QueryString.AllKeys) 18 { 19 20 if (!k.Equals(key)) 21 { 22 keyValue = Request.QueryString[k]; 23 keyCurrent = k; 24 } 25 else 26 { 27 keyValue = value; 28 keyCurrent = key; 29 } 30 31 if (string.IsNullOrEmpty(keyValue)) 32 { 33 continue; 34 } 35 36 if (handedCount++ != 0) 37 { 38 pathBuilder.AppendFormat("&{0}={1}", keyCurrent, keyValue); 39 } 40 else 41 { 42 pathBuilder.AppendFormat("{0}={1}", keyCurrent, keyValue); 43 } 44 } 45 return pathBuilder.ToString(); 46 } 47 } 48 return string.Format("{0}?{1}={2}", Request.Path, key, value); 49 }
Asp.net 插入或更改查询字符串,布布扣,bubuko.com
标签:style blog color os for ar div amp
原文地址:http://www.cnblogs.com/yomho/p/3904628.html