Environment:
Cluster of multiple web servers (Microsoft IIS) connected through load balancer sharing ASP.NET session variables by using SQLServer mode of <sessionState> configuration.
Symptoms:
Session variables are randomly lost and recovered when switching between web servers. Depending on which web server handles the request session variables are different. Some web servers seems to share same set of variables. Others have different set of variables.
Reason:
All web site identifiers must be equal at all of web servers. They act as application identifier and each application have separate pool of session variables.
In my case five of six web servers had equal web site identifiers. The sixth server had different web site identifier. All requests redirected to it seen different session variables than accessible at other web servers.
To check web site identifier
- Open Start / Administrative Tools / Internet Information Services (IIS) Manager
- Navigate to (server name) / Web Sites
- Switch right pane of console to Details view.
- You will see columns: Description, Identifier, State, Host header value, IP address, Port, SSL Port, Status
- Read web site identifier from column “Identifier”
- Verify if all web servers have equal web site identifier.
To change web site identifier
- Stop the web site (right click at IIS manager and select Stop, there is no need to stop entire IIS).
- Open command line console and change current directory to “C:\Inetpub\AdminScripts”.
- Run following command:
cscript adsutil.vbs move w3svc/currentid w3svc/newid - where “currentid” is current web site identifier and “newid” is new web site identifier.
- Start the web site.
Posted by Michał Krawczyk
Posted by Narawen Software