Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

StateServer session state mode management - Part 65

Suggested Videos
Part 62 - session state
Part 63 - Cookie less sessions in
Part 64 - Inporc session state mode management

In this video, we will discuss about the session state mode - StateServer. session state mode can have any of the following 4 values. session state mode is set in web.config file.
1. Off - Disables session state for the entire application.
2. InProc - Discussed in Part 64
3. StateServer - Will be discussed in this session.

The following session state modes will be discussed in a later video session.
4. SQLServer
5. Custom

When the session state mode is set to StateServer, the session state variables are stored in a process, called as state service. This process is different from the worker process. The state service can be present on a web server or a dedicated machine. 

Steps to follow, to configure web application to use StateServer:
1. Start the ASP.NET state Service. To start the state service
    a) Click Start > Type Run > Press Enter
    b) In the run window, type services.msc and click OK.
    c) In the services window, right click on ASP.NET State Service and select Start.
2. In web.config set sessionState mode="StateServer"
3. Set stateConnectionString="tcpip=StateServer:42424"
    Example: <sessionState mode="StateServer"     stateConnectionString="tcpip=localhost:42424"  

Advantages of using StateServer session state mode:
1. ASP.NET worker process independent. Survives worker process restart. 
2. Can be used with web farms and web gardens.
3. State server offers more scalability than InProc.

Dis-advantages of using StateServer session state mode:
1. StateServer is slower than InProc
2. Complex objects, need to be serialized and deserialized
3. If the StateServer, is on a dedicated machine, and if the server goes down all the sessions are lost.

Web Garden - Web application deployed on a server with multiple processors
Web Farm - Web application deployed on multiple server state server

1 comment:

  1. Question... you mentioned "The state service can be present on a web server or a dedicated machine."
    when you said "service can be presented on a web server"... then which server in case of Web Farm. There are more than one so does it save on all servers despite user request was redirected to e.g. Server 1. What about next request that can be redirected to Server 2. Otherwise it seems it behave same as InProc with regards to keeping the variable.


It would be great if you can help share these free resources