C#获取url中参数键值对的方法

方法如下:

/// <summary>
/// 遍历Url中的参数列表
/// </summary>
/// <returns>如:(?userName=keleyi&userType=1)</returns>
public string GetUrlParam()
{
string urlParam = "";
if (Request.QueryString.Count > )
{
urlParam = "?";
NameValueCollection keyVals = Request.QueryString;
foreach (string key in keyVals.Keys)
{
urlParam += key + "=" + keyVals[key] + "&";
}
urlParam = urlParam.Substring(, urlParam.LastIndexOf('&'));
}
return urlParam;
}
上一篇:2017.3.31 spring mvc教程(七)多视图控制器


下一篇:透彻分析反射的基础_Class类