2 February 2014

State Server (Out Process Session)

         A second option, accomplished by setting the mode attribute to StateServer, is storing session data in a separate in-memory cache controlled by a Windows service running on a separate machine.

        The state service, called the ASP.NET State Service (aspnet_state.exe), is configured by the stateConnectionString attribute in the Web.configfile. It specifies the service’s server and the port it monitors:

<sessionState mode="StateServer"
stateConnectionString="tcpip=myserver:42424" cookieless="false" timeout="20" />

  
       In this case, the state service is running on a machine called myserver on port 42424, which is the default. At the server, the port can be changed by editing the Port value in the HKLM\SYSTEM\CurrentControlSet\Services\aspnet_state registry key. Obviously, using the state service has the advantages of process isolation and sharability across a web farm.
      
       However, if the state service is stopped, all session data is lost. In other words, the state service does not persistently store the data as SQL Server does; it simply holds it in memory.

Implementation of State Server:


<configuration>
   <system.web>
   <sessionstate mode="state server" state connectionstring="tcpip=samplestateserver:42424"
      cookieless="false" timeout="20"/>
   <system.web>
</configuration>

    Objects stored in session state must be serializable if the mode is set ti state server

    To use stateserver mode in a web farm ,you must have the same encryption keys specified in the machine key element of our web configuration for all applications that are part of the web farm 

No comments:

Post a Comment