With SQL server session state session data is serialized and
stored in a database table in the SQL Server database.
1. If IIS restart
session data not affected /application not affected with inProc session we face
this issue frequently.
2. More Secure and reliable compared with InProc and state server.
3. Usefull in Web farm and Web gardens scenarios.
issue is main disadvantage (processing is slow), with SQL server session state
application is slow compared with InProc.
2. Object serialization and de serialization requires crates overhead and
network traffic issue.
3. External configuration required for sql server session state.
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.
//store session value
Session["UserName"] = UsernameTextBox.Text;
//retrieve session value.
var currentUser= (string)Session["UserName"];
state supports three modes:
1. This mode stores the
session data in the ASP.NET worker process.
2. This is the fastest among all of the storage modes.
3. This mode effects performance if the amount of data to be stored is large.
4. If ASP.NET worker process recycles or application domain restarts, the
session state will be lost.
1. In this mode, the
session state is serialized and stored in memory in a separate process.
2. State Server can be maintained on a different system.
3. State Server mode involves overhead since it requires serialization and
de-serialization of objects.
4. State Server mode is slower than InProc mode as this stores data in an
this storage mode, the Session data is serialized and stored in a database
table in the SQL Server database.
1. This is reliable and
secures storage of a session state.
2. This mode can be used in the web farms.
3. It involves overhead in serialization and de-serialization of the objects.
4. SQL Server is more secure than the InProc or the State server mode.