ASP.NET State Service Tutorial : Implementing State Server Session In ASP.NET

In this article, we will show you how can we implement “state server” session state management technique in

Bellow are steps for implementing “State Server” session management technique.

  • Add configuration in of Web.Config.

<sessionState mode=”StateServer” stateConnectionString=”tcpip=″/>

Here, mode=”StateServer” means session mode is “State Server”. Other modes are inproc, SQL server & custom.
stateConnectionString=”tcpip=″ means session state windows service is running on (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).

  • Starting “StateServer” windows service

Go to services (gor to Run => services.msc) & find “ASP.NET State Service”.

Change startup type of“ASP.NET State Service”to “Automatic” & start the service.

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 ’′ as the server name.”

To solve this error follow bellow steps

  • Go to machine where windows service is running.
  • Go to registry (Go to Run => regedit)
  • Go to this path -> “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection”

  • Change Value of parameter “AllowRemoteConnection” from 0 to 1.

Here you also change port number as well by changing Value of “PORT” parameter.

  • 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. revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality – beyond other hosting control panels – and ease of use, Plesk Control Panel is available only to HostForLIFE’s customers. They offer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.