HttpContext.Session is null behind Application Request Routing (ARR)

935 Views Asked by At

I'm struggling with the following issue. The setup:

  • ASP.NET webforms application on .NET 4.
  • Session State by State Service.
  • Three webservers. All three host the webapplication. One is also acting as the ARR Controller.

Webserver 1: Windows 2012. IIS 8. ASP.NET State Service. ARR Controller.

Webserver 2: Windows 2012. IIS 8.

Webserver 3: Windows Server 2008R2. IIS 7.5. ASP.NET 4.5.2 is installed.

While navigating/switching between the servers, the Httpcontext.Session is null:

HttpContext context = HttpContext.Current;
if (context.Session == null)
{
    CurrentLogger.Logger.Info("Context.Session is null");
}

If I'm lucky, and the request redirects to the same server, It keeps the session.

The sessionState server is configured like this:

<sessionState mode="StateServer" stateConnectionString="tcpip=192.168.2.53:42424" cookieless="false" timeout="30" />

I've also set the machine Key:

<machineKey validationKey="[xxxxx]" decryptionKey="[xxxx]" validation="SHA1" />

I require all my cookies to be sent only over SSL. Using IIS logging I see that this isn't a problem. The auth & session cookies are beïng sent to all webservers.

What might cause my session to be null between the servers?

1

There are 1 best solutions below

0
On

The solution is found here: https://stackoverflow.com/a/456238/167196.

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.