• 欢迎访问一起聊聊,欢迎加入一起聊聊 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏一起聊聊吧

遍历Cache,COOKIE,SESSION,Applocation

程序教程 admin 2020-07-23 15:50:20 993次 0条 未收录

遍历Cache

Response.Write("<p>Cache的所有值:</p>");
IDictionaryEnumerator CacheEnum = HttpRuntime.Cache.GetEnumerator();
//总数
Response.Write("<p>" + HttpRuntime.Cache.Count + "</p>");
//所有
while (CacheEnum.MoveNext())
{
    //名称
    Response.Write("<p>" + CacheEnum.Key + ":" + Cache[CacheEnum.Key.ToString()] + "</p>");
}

COOKIE

Response.Write("<p>Cookie的所有值:</p>");
for (int i = 0; i < HttpContext.Current.Request.Cookies.Count; i++)
{
    Response.Write("<p>" + HttpContext.Current.Request.Cookies.Keys[i] + ":" + HttpContext.Current.Request.Cookies[i].Value.ToString() + "</p>");
}

遍历SESSION

Response.Write("<p>Session的所有值:</p>");
foreach (string obj in Session.Contents)
{
    Response.Write("<p>" + obj.ToString() + ":" + Session[obj] + "</p>");
}

遍历Applocation

Response.Write("<p>Application的所有值:</p>");
for (int i = 0; i < HttpContext.Current.Application.Count; i++)
{
    Response.Write("<p>" + HttpContext.Current.Application.Keys[i] + ":" + HttpContext.Current.Application[i] + "</p>");
}

一起聊聊 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:遍历Cache,COOKIE,SESSION,Applocation
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址