List all session info

前端 未结 3 1277
天命终不由人
天命终不由人 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]) + "
    "); }

    2nd method

    foreach (var crntSession in Session)
    {
        Response.Write(string.Concat(crntSession , "=", Session[crntSession .ToString()]) + "
    "); }

提交回复
热议问题