Sharing ASP.NET State Service sessions between IIS7.5 and 8.0 doesn’t work

asp.netiis-7.5iis-8windows-server-2008-r2windows-server-2012

I've got a web farm consisting of 5 Server 2008R2 machines running IIS 7.5. All of them share session state using a single, separate, server running the ASP.NET State Service (this one also runs 2008 R2). Everything is working wonderfully.

However, I've now added a sixth server, this one running 2012/IIS 8.0. For the life of me, I can't get this server to share session state with the other servers.

The machineKey configuration is the exact same (anonymized):

<machineKey validationKey="XYZ" decryptionKey="ZYX" validation="SHA1" />

The application ID is the exact same across all servers (we run multiple websites, but all have the ID created programmatically, config is identical, verified at runtime as well):

/LM/W3SVC/10351/ROOT

All sites also have the same AppPath, also verified at runtime:

D:\SomeSite\SomApp\

The session configuration is the exact same as well:

<sessionState mode="StateServer" partitionResolverType="MyStateServerPartitionResolver" stateNetworkTimeout="30" timeout="20" />

The MyStateServerPartitionResolver class is very simply, just abstracting the fact that we load the connection string through our own configuration (connectionString value is identical on all servers, also verified):

public class MyStateServerPartitionResolver : IPartitionResolver
{
    private string connectionString;

    public void Initialize()
    {
        connectionString = ConfigSettings.StateServerConnectionString;
    }

    public string ResolvePartition(object key)
    {
        return connectionString;
    }
}

All sites run on .NET 4.0 and the application pool configuration is the exact same as well.

The only difference I can narrow it down to is the fact that the working servers are all running IIS 7.5 while the non-working one is running IIS 8.0. However, I'd expect this to be a supported scenario as it's hard to do a rolling upgrade otherwise.

Any suggestions on what I can do to debug this? Or any documentation confirmation that IIS 7.5 & 8.0 can't share session state?

Best Answer

So this turned out to be a classic moment of staring yourself blind on the simple issue.

While all machines were fully updated and configuration was identical, I missed the fact that Server 2012 is born with .NET 4.5 installed natively. And even though you select v4.0 as the .NET Framework version in IIS, it's actually running 4.5 behind the scenes.

And as luck would have it, the session key changed between 4.0 and 4.5, thus causing us to loose sessions when the user was switched between servers running 4.0 and 4.5.

Installing the .NET 4.5 Framework on all 2008 R2 servers has fixed the issue.