Setting up Web Sites to run in State Server mode

From Catglobe Wiki
Revision as of 10:05, 7 March 2011 by 127.0.0.1 (talk | contribs) (jrfconvert import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Setting up Web Sites to run in State Server mode

1. Introduction

StateServer mode stores session state in a process, referred to as the ASP.NET state service, that is separate from the ASP.NET worker process or IIS application pool. Using this mode ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.

2. Enabling APSNET_STATE process

To use StateServer mode, you must first be sure the ASP.NET state service is running on the server used for the session store. The ASP.NET state service is installed as a service when ASP.NET and the .NET Framework are installed. Please be noticed that the service is stopped by default.

Services

StateService-Settings

3. Configuring Webserver: metabase path

To maintain session state across different Web servers in the Web farm, the application path of the Web site (for example, \LM\W3SVC\2) in the Microsoft Internet Information Services (IIS) metabase must be the same for all of the Web servers in the Web farm. The case also needs to be the same because the application path is case-sensitive. In case they are not the same, we need to synchronize them.

3.1 Finding the instance ID of a Web Sites

Open the IIS Manager console, click on the Web Sites folder in the left pane, you will see the instance ID in the right pane (the number under the Identifier column.)

InstanceID

Synchronizing instance Ids of web sites on a web farm

You can find instructions about how to synchronize instance ids of web sites on a web form on the following MSDN article: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q325056

4. Configuring webconfig files

4.1. The sessionState key

In the webconfig file, search for the sessionState key. It should look like this:

<sessionState mode="StateServer" stateConnectionString="tcpip=server:port" cookieless="..." timeout="number of minutes" />

mode: Specifies where to store session state values, must be "StateServer"

stateConnectionString: Specifies the server name or address and port where session state is remotely stored. The port value must be 42424.

cookieless: Specifies how cookies are used for a Web application. It should be set to false.

Timeout: Specifies the number of minutes a session can be idle before it is abandoned.

Example: given that the IP of the state server is 10.0.0.6, then the setting is:

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

4.2. MachineKey

To use StateServer mode in a Web farm, you must have the same encryption keys specified in the machineKey element of your Web configuration for all applications that are part of the Web farm. For information on how to create machine keys, see the Deployment – Setting up the web config file section.