List all session info

前端 未结 3 1169
天命终不由人
天命终不由人 2021-02-18 23:53

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 is C#.

相关标签:
3条回答
  • 2021-02-19 00:35

    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 />");
    }
    
    0 讨论(0)
  • 2021-02-19 00:41

    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 />");
                }
    
    0 讨论(0)
  • 2021-02-19 00:45
     foreach (string s in Session) {
            Response.Write(string.Concat(s, "=", Session[s]));
        }
    
    0 讨论(0)
提交回复
热议问题