Session State in ASP.net
What is a Session?
A session is the duration of connectivity between a client and a server application. ASP.net session state enables you to store and retrieve values for a user as the user navigates ASP.net pages in a Web application.
SessionState Mode in asp.net
There are different types of sessions state mode in asp.net such as In-Proc, State-Server, SQL Server. Let me describe in brief.
- In-Proc - In this mode of session, state is stored in the memory space of the aspnet_wp.exe (worker process). This is the default setting. If the IIS reboots or web application restarts then session state is lost.
- State-Server - In this mode of session, state is serialized and stored in a separate process (aspnet_state.exe), therefore, the state can be stored on a separate computer (a state server).
- SQL Server - In this mode of session, state is serialized and stored in a SQL Server database.
Session state can be specified in <sessionState> element of application configuration file (web.config). Using state server and SQL Server session state can be shared across web forms but always remember this comes at speed cost as ASP.NET needs to serialize and deserialize data over network repeatedly.
Is Session_End event supported in all session modes?
Session_End event occurs only in In-proc mode. State-Server and SQL Server do not have Session_End event.
How can we kill a user session?
What is a asp.net session Id?
A session id is used to identify request from the browser. By default, value of SessionId is stored in a cookie. You can configure the application to store SessionId in the URL for a "cookieless" session.
I hope you will enjoy the interview tips while learning asp.net mvc session. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome. Also If you like this article, don't forget to share this article with your friends and colleagues
Session State in ASP.net Reviewed by Ravi Kumar on 9:13:00 AM Rating: