C# Request.Params与Request.QueryString 的区别

1.Request.Params包含Request.QueryString,request.form、request.cookies和request.servervariables。这几种
查找的时候会在三个当中去找,而Request.QueryString 只包含请求字符串本身,所以Request.QueryString有的在Request.Params中是找得到的

2.都是对传递过来的参数的获取。

using System.Web;

 /// <summary>
/// 获取网页传过来的值
/// </summary>
/// <param name="strKey">参数</param>
/// <returns>返回的是参数的值</returns>
public string GetRequestValue(string strKey)
{
//第一种写法:
return string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[strKey]) ? HttpContext.Current.Request.QueryString[strKey] : string.Empty;
//第二种写法:要比第一种写法要好些;
return string.IsNullOrEmpty(HttpContext.Current.Request.Params[strKey]) ? HttpContext.Current.Request.Params[strKey] : string.Empty; 

}

 具体可以推荐:http://www.cnblogs.com/jack-liang/archive/2011/04/01/2001868.html

原文地址:https://www.cnblogs.com/allenhua/p/3340272.html