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#.
php session_start(); echo "<h3> PHP List All Session Variables</h3>"; foreach ($_SESSION as $key=>$val) echo $key." ".
Yes, you can store any object (I assume you are using ASP.NET with default settings, which is in-process session state): Session["test"] = myList; You should cast it back to the original type for use: var list = (List<int>)Session["test"]; // list.
These two methods is working for me, improved and corrected David's answer slightly:
for (int i = 0; i < Session.Count; i++)
{
var crntSession = Session.Keys[i];
Response.Write(string.Concat(crntSession, "=", Session[crntSession]) + "<br />");
}
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]));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With