SQL Server stored ASP.NET Session variables are lost when switching web servers

November 20, 2008

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

  1. Open Start / Administrative Tools / Internet Information Services (IIS) Manager
  2. Navigate to (server name) / Web Sites
  3. Switch right pane of console to Details view.
  4. You will see columns: Description, Identifier, State, Host header value, IP address, Port, SSL Port, Status
  5. Read web site identifier from column “Identifier”
  6. Verify if all web servers have equal web site identifier.

To change web site identifier

  1. Stop the web site (right click at IIS manager and select Stop, there is no need to stop entire IIS).
  2. Open command line console and change current directory to “C:\Inetpub\AdminScripts”.
  3. Run following command:
    cscript adsutil.vbs move w3svc/currentid w3svc/newid
  4. where “currentid” is current web site identifier and “newid” is new web site identifier.
  5. Start the web site.

IIS does not want to start after change of IP

October 13, 2008

The IIS 6.0 installed at Windows 2003 Small Business Server refused to start. All web sites reported following error:

The format of the specified network name is invalid

Additionally in System event log following errors were logged:

EventID 1004 from W3SVC: Cannot register the URL prefix …. for site …. The site has been deactivated.

and

Event ID 1005 from HTTP: Unable to bind to the underlying transport for …. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine.

I checked if IIS websites were configured to listen on old IP address only… but no… they were set to “All unassigned”.

Also I checked if nothing blocks ports 80 and 443 when IIS is stopped….

After some research I found this Microsoft TechNet page: Configuring the IP Inclusion List (IIS 6.0) which mentiones both events and refers to “httpcfg” utility which is used for configuration of HTTP protocol bindings.

Unfortunatelly I was working at remote desktop without access to installation CD to install Windows Support Tools containing “httpcfg”. But the solution was quite simple…

What I did to fix:

  1. Opened the Registry Editor
  2. Navigated to “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters”
  3. At “ListenOnlyList” registry value there was a reference to old IP address.
  4. Changed the old IP address to new one in “ListenOnlyList” value.
  5. Restarted HTTP service (“net stop http / net start http”)
  6. Restarted IIS service (“net stop w3svc / net start w3svc”)

And it works now…


“Unexpected Error 0×8ffe2740 Occurred” when trying to start a Web Site in IIS

May 28, 2008

Today I was surprised by IIS refusing to start at my computer due to cryptic:

Unexpected Error 0×8ffe2740 Occurred

Quick googling pointed Microsoft Knowledge Base Article KB816944 saying:

This behavior may occur if a port conflict exists on the system. By default, IIS uses port 80 for HTTP communication. If an application other than IIS is running and is using port 80 on the same IP address, you may receive the error message when you try to use IIS Manager to start the Web site.

OK. But which application dares to use port 80 at my computer?

The culprit – Skype. Sometimes it uses ports 80/443…

To disable it:

  1. Open Skype
  2. Select Tools / Options
  3. Select “Connection” tab
  4. Disable “Use port 80 and 443 as alternatives for incoming connections”

Now IIS can start a web site.

 


One of possible reasons why IIS generate “Service Unavailable” message

May 28, 2008

We were setting up static web site with IIS running at Windows 2003 Server. The site was just plain HTML files with images and CSS so “nothing to break”.

Unfortunatelly always the result was the same:

Service Unavailable

The reason? Simple… at web server ASP.NET applications were configured in application pools. The static site has “Execute permissions: None” which disables the application pool configuration option at web site properties page.

But it does not mean that the application pool is not needed. It is “DefaultAppPool”… and it was disabled (because of being not used).

So… if you see “Service Unavailable” message first check if application pool is started and remember that for non-application web sites it is “DefaultAppPool”.