Session State Modes
By default, all session state information is managed in the same Windows process that the Web server and ASP.NET run in. This is known as running in process
. A clear advantage of running in process is performance since all the data is immediately available to the Web server. However, storing the session state in process can have some disadvantages.
- A Web server crash will lose all the current session data.
- You lose session data if the application is restarted for any reason.
- In process session state cannot be shared across multiple Web servers so this limits the scalability of your site. Obviously this is a problem if you plan to scale up to a Web farm.
Fortunately, ASP.NET provides the capability to store session state variables out-of-process
. This means that the session state variables are NOT managed within the same Windows process that ASP.NET runs in. The advantage to managing session state out-of-process is that users can seamlessly move from Web server to Web server (though they don't know it) and still maintain their state. Table 2 lists the session state modes available in ASP.NET.
Table 2: The session state modes available in ASP.NET.
Session state data is stored in the same process as the ASP.NET worker process (default).
Session state is not tracked.
Session state data is stored using an out-of-process server.
Session state data is stored using an out-of-process SQL Server.