How to use a separate Windows service for state management in ASP.NET

Software developer can set ASP.NET to use a separate Windows service for state management with option StateServer: When software developer is going to use this mode, the objects he store in the session state must be serializable. Otherwise ASP.NET will not be able to transmit the object to the state service.


<?xml version=”1.0” encoding=”utf-8” ?>
     <!— other settings are omitted. —>
        cookieless=”AutoDetect” cookieName=”ASP.NET_SessionID”
        sqlConnectionString=”data source=;Integrated Security=SSPI”
        sqlCommandTimeout=”30” allowCustomSqlDatabase=”false”


This service will work on the same web server, but outside the main ASP.NET process, which gives a basic level of protection if the ASP.NET process has to be restarted. When state information is transferred between two processes time delay will be increased.

When this option is used, the software developer should specify a value for the stateConnectionString setting. This string identifies the TCP/IP address of the computer that is running the StateServer service and its port number. This allows software developer to host the StateServer on another computer. If he doesn’t change this setting, the local server, set as address, will be used. There is an optional attribute stateNetworkTimeout that specifies the maximum number of seconds to wait for the service to respond before canceling the request. The default value is 10 seconds.

Before application can use the service, the administrator has to start it. He can follow the next steps:
1. Select Start>Programs>Administrative Tools>Computer Management
2. Select Services and Application>Service node
3. Find the service called ASP.NET State Service in the list.
4. Now he can start and stop the service by right-clicking it.
5. He can modify its Startup Type setting to Automatic right-clicking it and select Properties. In this case Windows will automatically start the service.