请问c#高手,Request.ServerVariables["QUERY_STRING"]返回的是不是空值??

来源:百度知道 编辑:UC知道 时间:2024/09/23 06:58:03
if (System.Web.HttpContext.Current.Request.ServerVariables["QUERY_STRING"] != null)
{
sss = System.Web.HttpContext.Current.Request.ServerVariables["QUERY_STRING"].ToString().ToLower();
System.Web.HttpContext.Current.Response.Write(sss+"ok");
}

不是,字符串类型,用 !=""

Request.ServerVariables。它的原型是(可以用右键 点“转到定义”)
public NameValueCollection ServerVariables { get; }

而NameValueCollection 是个集合,原型里有获取值的方法

public string this[int index] { get; }
public string this[string name] { get; set; }
它返回的string类型。

所有楼上所言甚是。