3

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?

1

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.

1
  • I am unable to get the sessions shared between 2 websites using StateServer. I am doing this by setting the same _appDomainAppId, same session id in cookie ASP.NET_SessionId with same Domain and Path. Could you help me? – bjan Mar 7 '18 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.