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 asp.net 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 asp.net 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
- In process
- SQL Server
- State Server
- In process method stores data in the same asp.net 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
Asp.net 4 has a new feature – session state compression. Developers can leverage this feature in asp.net 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 asp.net. If you have any doubt or want to ask anything related to Sessions or asp.net, just comment in below section.