Asp.net 请求[]集合的内容是什么
当我作为集合访问请求对象时,它从何处获取数据 比如我知道Asp.net 请求[]集合的内容是什么,asp.net,Asp.net,当我作为集合访问请求对象时,它从何处获取数据 比如我知道 Request["someKey"] 将返回其中一个的值 Request.QueryString["someKey"] 或 取决于所设置的 是否搜索了其他集合(cookies、会话) 如果键值对存在于多个集合中,会发生什么情况 我查看了MSDN,但找不到太多信息 谢谢你的帮助 如果您反编译此程序集并查看源代码,它将在查询字符串中查找,然后在表单中查找,然后在Cookies中查找,然后在最后返回null之前,如果它们都不包含该项 pu
Request["someKey"]
将返回其中一个的值
Request.QueryString["someKey"]
或
取决于所设置的
是否搜索了其他集合(cookies、会话)
如果键值对存在于多个集合中,会发生什么情况
我查看了MSDN,但找不到太多信息
谢谢你的帮助 如果您反编译此程序集并查看源代码,它将在
查询字符串
中查找,然后在表单
中查找,然后在Cookies
中查找,然后在最后返回null
之前,如果它们都不包含该项
public string this[string key]
{
get
{
string item = this.QueryString[key];
if (item == null)
{
item = this.Form[key];
if (item == null)
{
HttpCookie httpCookie = this.Cookies[key];
if (httpCookie == null)
{
item = this.ServerVariables[key];
if (item == null)
{
return null;
}
else
{
return item;
}
}
else
{
return httpCookie.Value;
}
}
else
{
return item;
}
}
else
{
return item;
}
}
}
你应该看看这个链接啊,多有趣啊。谢谢我不知道这上面有没有官方文件?@Ev。将页面的
trace
模式设置为true
——您将看到所有内容。e、 g.
public string this[string key]
{
get
{
string item = this.QueryString[key];
if (item == null)
{
item = this.Form[key];
if (item == null)
{
HttpCookie httpCookie = this.Cookies[key];
if (httpCookie == null)
{
item = this.ServerVariables[key];
if (item == null)
{
return null;
}
else
{
return item;
}
}
else
{
return httpCookie.Value;
}
}
else
{
return item;
}
}
else
{
return item;
}
}
}