Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 请求[]集合的内容是什么_Asp.net - Fatal编程技术网

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;
        }
   }
}