In this tutorial I will show you that How can we implement “state server” session state management technique in asp.net
Bellow are steps for implementing “State Server” session management technique.
1. Add configuration in of Web.Config.
mode=”StateServer” menas session mode is “State Server”. Other modes are inproc, sqlserver & custom.
stateConnectionString=”tcpip=127.0.0.1:42424″ means session state windows service is running on 127.0.0.1 (this is same machine where I am running my application as well as service. If you are running windows service on other machine then put that machines IP) on port 42424 (this is default port on which service runs. This can bechanged in registry).
This configuration is enough if you have state server on same machine.
You might get bellow error if you are using other machine for storing state.
“Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either ‘localhost’ or ’127.0.0.1′ as the server name.”
To solve this error follow bellow steps
1. Go to machine where windows service is running.
2. Go to registry (Go to Run => regedit)
3. Go to this path -> “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection”
4. Change Value of parameter “AllowRemoteConnection” from 0 to 1. (Here you also change port number as well by changing Value of “PORT” parameter).
5. Now restart windows service.
Hope fully after doing this error will be gone & you will be able to implement “StateServer” session management technique successfully in ASP.NET.