• HttpRequest.Item 属性 和 HttpRequest.QueryString 属性的区别!


     

    HttpRequest.Item 属性 和 HttpRequest.QueryString 属性的区别!

    MSDN 关于这两个属性的说明


         属性:HttpRequest.Item

        说明:从 Cookies、Form、QueryString 或 ServerVariables 集合中获取指定的对象。


        属性:HttpRequest.QueryString 

        说明: 获取 HTTP 查询字符串变量集合。


    内部实现    

        用 Reflector 反编译 System.Web.dll 。查看 HttpRequest 类的属性 Item 的实现代码如下:

    代码1-1 

    public string this[string key]
    {
        
    get
        {
            
    string str = this.QueryString[key];
            
    if (str != null)
            {
                
    return str;
            }
            str 
    = this.Form[key];
            
    if (str != null)
            {
                
    return str;
            }
            HttpCookie cookie 
    = this.Cookies[key];
            
    if (cookie != null)
            {
                
    return cookie.Value;
            }
            str 
    = this.ServerVariables[key];
            
    if (str != null)
            {
                
    return str;
            }
            
    return null;
        }
    }

        从代码中,我们很清楚的看到, HttpRequest.Item 属性的内部实现:    

        1, 获取 HTTP 查询字符串变量集合。如果不存在执行第2步    

        2, 获取窗体变量集合。如果不存在则执行第3步    

        3, 获取客户端发送的 cookie 的集合。如果不存在则执行第4步  

        4, 获取 Web 服务器变量的集合。 如果不存在则返回 null    

        End。


  • 相关阅读:
    FSL
    64位MicrosoftOfficeWord加载EndnoteX7
    Lobes of the brain
    Anterior and posterior commissures
    Broadmann area (wiki)
    Broadmann分区
    matlab FDR校正
    AI图片剪切
    DPABI advanced edition 文件夹组织形式
    Frequently Asked Questions
  • 原文地址:https://www.cnblogs.com/bruceleeliya/p/1506019.html
Copyright © 2020-2023  润新知