Types of session management in ASP.NET

Home » .Net Interview Questions » Types of session management in ASP.NET
.Net Interview Questions No Comments

Types of session management

Session object is used to store state specific information per user basis.Session object can be configured 3 ways based on availability and scalability of web application.

1). In Process Mode:
This is default mode and useful for small application which is hosted on single server.
Advantages:
-Fastest mode.
-Simple configuration.
Disadvantages:
-Session data will be lost if worker process or application domain recycle.
-Not ideal for web garden and web form.

2). Out-of-process session mode(State server mode):
This mode is useful for highly available and scalable applications.Session state is stored in a process called aspnet_state.exe that runs as a windows service which listens on TCP port 42424 by default.
Advantages:
-Supports web farm and web garden configuration.
-Session data is persisted across application domain recycles.This is achieved by using separate worker process for maintaining state.
Disadvantages:
-Out-of-process mode provides slower access compared to in process.
-Requires serializing data.

3). Sql-Backed Session State: Session can also be stored in sql server database.Storing session in DB offers resilience that can serve session to a large web farm that persists across IIS restarts.SQL based session state is configured with aspnet_regsql.exe.
Advantages:
-Supports web farm and web garden configuration.
-Session State is persisted across application domain recycles and even IIS restarts.
Disadvantages:
-Required serialized of objects.