List all session info
I want to display all the session information of my asp.net page (aspx) in the page. How can I do that?
The programming language 开发者_JAVA技巧is C#.
These two methods is working for me, improved and corrected David's answer slightly:
1st method
for (int i = 0; i < Session.Count; i++)
{
var crntSession = Session.Keys[i];
Response.Write(string.Concat(crntSession, "=", Session[crntSession]) + "<br />");
}
2nd method
foreach (var crntSession in Session)
{
Response.Write(string.Concat(crntSession , "=", Session[crntSession .ToString()]) + "<br />");
}
foreach (string s in Session) {
Response.Write(string.Concat(s, "=", Session[s]));
}
Display in listbox ( Adding for personal reference)
int[] array = new int[400];
for (int i = 0; i < Session.Count; i++)
{
var crntSession = Session.Keys[i];
lstbx.Items.Add(crntSession + "=" + Session[crntSession] + "<br />");
}
精彩评论