//在VS2008中循环显示Session:
方法1:
foreach (string key in Session.Contents)
{
Response.Write(key.ToString() + ": " + Session[key].ToString() + "<br>");
}
方法2:
for (int i = 0; i < Session.Contents.Count; i++)
{
Response.Write(Session.Keys[i].ToString() + ": "+ Session[i].ToString() + "<br>");
}
//在VS2008中循环显示Cookies:
Response.Write("<br>Cookies的所有值:<br>");
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>");
}
//在VS2008中循环显示Application:
Response.Write("<br>Application的所有值:<br>");
for (int i = 0; i < HttpContext.Current.Application.Count; i++)
{
Response.Write(HttpContext.Current.Application.Keys[i] + ": " + HttpContext.Current.Application[i].ToString() + "<br>");
}
作者:zeke
出处:http://zhf.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。