How To Work With Sessions in ASP.NET


HTTP is a stateless protocol, which means every moment when a new request is made by the client for the server, the state information of the previous request is lost.

There are many methods to store and handle state in and Session object is among those methods. Caching and Application objects are other objects used for same job.

Caching helps in enhancement of the app performance by lowering the consumption of resources in the system.


You can store rapidly used data or web pages in order to enhance the performance, output and scalability of the application by reducing the consumption of the resources of the server.

A Session in is a session of connectivity between the client and the server. It is the Session object that holds data that communicate to a users’ session. It is a server side state management technique used for storing user centric information into memory for future recovery.

Methods of Storing Session Data

There are four methods to store session data

  1. In process
  2. SQL Server
  3. State Server
  4. Custom
  • In process method stores data in the same process.
  • SQL Server process stores data in the SQLServer database.
  • State Server method stores data in some other system.
  • Custom method allows you to store session data with a custom storage provider.

New Session data compression support 4 has a new feature – session state compression. Developers can leverage this feature in 4 and updated version to compress session data in order to store out-of-process sessions.

They need to set the compressionEnabled attribute to “true” in the app configuration file. Take an example:


Session state allows developers to store user centric data to the memory and recognize a specific request in unique way. It can be stored as key/value and can be accessed with HttpContect.Session property.


Professional .Net Developer just shared a blog about Sessions to make you understand about their working in If you have any doubt or want to ask anything related to Sessions or, just comment in below section.

Read:  How To Speed Write Your Articles To Success

Recommended For You

About the Author: Dharak Infotech

Contact on for Guest Post, Sponsored Posts or Advertisement Solutions.

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.