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

StateServer asp.net session state mode management - Part 65

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

In this video, we will discuss about the asp.net session state mode - StateServer. Asp.net session state mode can have any of the following 4 values. Asp.net 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 asp.net state service. This process is different from the asp.net worker process. The asp.net state service can be present on a web server or a dedicated machine. 

Steps to follow, to configure asp.net web application to use StateServer:
1. Start the ASP.NET state Service. To start the asp.net 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"  
              timeout="20"></sessionState>



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.

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

asp.net state server

1 comment:

  1. Question... you mentioned "The asp.net 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.

    ReplyDelete

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