POST参数进行排序

POST参数进行排序

 private static string GetSortedParas(Dictionary<string, string> dic)
{
dic = dic.OrderBy(key => key.Key).ToDictionary(keyItem => keyItem.Key, valueItem => valueItem.Value);
var sbPara = new StringBuilder();
foreach (var para in dic.Where(para => !para.Value.IsNullOrWhiteSpace()))
{
sbPara.AppendFormat("{0}={1}&", para.Key, para.Value);
}
return sbPara.ToString().TrimEnd('&');
}

C#代码实现对HTTP POST参数进行排序

05-11 13:38