asp.net遍历缓存、session、cookies、application

//遍历缓存
        foreach (DictionaryEntry de in Cache)
        {
            Response.Write(string.Format("<br>{0}:{1}", de.Key, de.Value));
        }

 

//遍历session
        for (int i = 0; i < HttpContext.Current.Session.Count; i++)
        {

            Response.Write(HttpContext.Current.Session.Keys[i] + ":" + HttpContext.Current.Session[i].ToString() + "<br>");
        }

 

//遍历cookies
        for (int i = 0; i < HttpContext.Current.Request.Cookies.Count; i++)
        {

            Response.Write(HttpContext.Current.Request.Cookies.Keys[i] + ":" + HttpContext.Current.Request.Cookies[i].Value.ToString() + "<br>");
        }

 

//遍历application

        Response.Write("ap<br>");
        for (int i = 0; i < HttpContext.Current.Application.Count; i++)
        {

            Response.Write(HttpContext.Current.Application.Keys[i] + ":" + HttpContext.Current.Application[i].ToString() + "<br>");

        }



posted @ 2010-11-26 12:21  郭小俊  阅读(496)  评论(0编辑  收藏  举报