//在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>");
}