62,046
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// Request获取传参
/// </summary>
/// <param name="strName">参数</param>
/// <param name="values">错误时返回此数据</param>
/// <returns></returns>
public static string Request(string strName,string values)
{
if (HttpContext.Current.Request.QueryString[strName] == null || HttpContext.Current.Request.QueryString[strName] == "")
{
return values;
}
else
{
//参数直接过滤,如有特殊符号,HTML,JS,SQL 过滤
return HTML(HttpContext.Current.Request.QueryString[strName].ToString().Trim());
}
}
public static bool IsNullOrEmpty(string value)
{
if (value != null)
{
return (value.Length == 0);
}
return true;
}
反编译QueryString属性
public NameValueCollection QueryString
{
get
{
if (this._queryString == null)
{
this._queryString = new HttpValueCollection();
if (this._wr != null)
{
this.FillInQueryStringCollection();
}
this._queryString.MakeReadOnly();
}
if (this._flags[1])
{
this._flags.Clear(1);
ValidateNameValueCollection(this._queryString, "Request.QueryString");
}
return this._queryString;
}
}
var value = HttpContext.Current.Request.QueryString[strName];
if(string.IsNullOrEmpty(value)) return values;
return HTML(value.Trim());