不同的容器,HttpContext.Current.Items只在当前请求时有用,但HttpContext.Current.Cache["SiteSettings"]只要没被毁掉,可以为多个请求,多个用户所用

解决方案 »

  1.   

    1、“HttpContext.Current.Items只在当前请求时有用”这句话是什么意思啊?
    2、“HttpContext.Current.Cache["SiteSettings"]”是不是与“HttpContext.Current.Appliction["SiteSettings"]”功能一致啊?
      

  2.   

    HttpContext.Current.Cache   它是一个应用程序域内的http请求的缓存.   
    HttpContext.Current.Items   它是一个应用程序域内的某个客户端的一次请求数据集合. 
      

  3.   

    那是否可以理解为:
    HttpContext.Current.Items就像Session对象,而
    HttpContext.Current.Cache就像Appliction对象呢?
    另外,我在微软出的“ASP.NET Portal Starter Kit”的程序中,看到程序一会儿用到HttpContext.Current.Cache,一会儿又用到HttpContext.Current.Items,简直把我搞糊涂了,
    不知道什么时候应该用到HttpContext.Current.Cache,
    什么时候又该用HttpContext.Current.Items,
    请大家告诉我一下,谢谢啦!!
      

  4.   

    HttpContext.Current.Cache存储的全局变量,是所有在线的用户共享的。
    HttpContext.Current.Items存储的是当前用户自己的数据,别人是不能用的。我说的,比较粗,建议去MSDN好好查查。
      

  5.   

    嗯,楼上的说的对!
    不过,我看过MSDN了,但
    HttpContext.Current.Items与Session,
    HttpContext.Current.Cache与Appliction
    的区别还是没有搞懂,不好意思,希望楼上的兄弟给指点一下,呵呵!!
      

  6.   

    HttpContext.Current.Items 的生命周期和httprequest 同步, session不是啊
      

  7.   

    HttpContext.Current.Cache怎么清除所有的缓存的数据呢?
    用HttpContext.Current.Cache.Remove(key);可以吗?
    怎么我有时候会不行的哦。