Get list of all active session variables in ASP.NET

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 !!

Subscribe To Newsletter For your Daily Development Tips and Tricks  

 Best Tips & Tricks on Microsoft Technology Platform 

Invalid email address
We promise not to spam you. You can unsubscribe at any time.
Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.