Following are the different types of session modes available in ASP.Net.
If we set Session Mode="off" in web.config, Session will be disabled to all over the application. For this we need to configure web.config in following way
This is the default session mode in Asp.Net. Its stores session Information in Current Application Domain. This is the best session mode which is based on web application Performance. But main disadvantage is that, It will lose the data if we restart the server. There are some more advantages and disadvantages of InProc session mode. I will come to those points again .
As I have already discussed InProc mode session data will be stored on the current application domain. So It is easily and quickly available.
So, InProc session mode store its session data in a memory object on that application domain. This is handled by worker process in application pool. So If we restart the server we will lose the session data. If Client request for the data , state provide read the data from In-Memory Object and return it to the client. Inweb.config we have to mention Session mode and also we have to set the Timeout.
This Session TimeOut Setting keeps session alive for 30 minute. This can be configurable from Code behind too.
Collapse | Copy Code
There are two type of session events available in asp.net Session_Start() and Session_End. It is the only mode that supports the Session_End() event. These events will call after the session timeout period is over. The general flow for the InProc Session State is some thing like this.
Now, when the Session_End() will call that depends on Session Time Out. This is a very fast mechanism because no serialization occurs for storing and retrieving data, and data are staying inside the same application domain.