In this post I am going to discuss about how you can get list of all active Session Variables in ASP.NET Application. The easiest way to get the details of session variable is using “Tracing” . If you enable the “Tracing
” for your application, you can get list of all Active Session variables
. Another alternative way is, get all the list of session variable using “Session.Contents
”.
To illustrate, Let me store some dummy data to in some session variables,
Now, if you enable tracing in your page and inspect the Session State section, you will get the list of all session variable along with their type and values.
Now, if you want to read the same session variable programmatically, you have to use “Session.Contents
”. Session.Contents returns the current System.Web.SessionState.HttpSessionState
Once done, you will get below details (here sessionItems
is a multiline Text here )
Hope this will help you !!