I have a ASP.NET MVC workflow configured as two websites managed by a load balancer. The websites use Sql Server as the session state provider and have authentication switch off (its not required).
Now, sporadically I appear to be losing session state, and I believe this is because the request is being handled by the alternative server, so essentially the user is jumping from server to server, depending how the load balancer sees fit. I am not always "losing session state" at the same stage in the workflow, so I believe it is something related to the web farm configuration + sql server session state.
Both applications use the same machine key to encrypt and decrypt session state stored in sql server.
The configuration on both servers is as follows:
<authentication mode="None" />
<sessionState mode="SQLServer" sqlConnectionString="{connection-string}" />
<machineKey decryptionKey="777CB456774AF02F7F1AC8570FAF31545B156354D9E2DAAD"
validationKey="89B5B536D5D17B8FE6A53CBB3CA8B8695289BA3DF0B1370BC47D362D375CF91525DDB5307D8A288230DCD4B3931D23AED4E223955C45CFF2AF66BCC422EC7ECD" />
I've confirmed that this is identical on both servers, is there something I am missing?
This does not occur in my development environment when I am using a single server.
I fear I am suffering from the Friday blues, and no doubt will figure out the answer next week, sadly I don't want to wait!
Any ideas?
Custom mode specifies that you want to store session state data using a custom session state store provider. When you configure your ASP.NET application with a Mode of Custom, you must specify the type of the session state store provider using the providers sub-element of the sessionState configuration element.
The session state is stored in the ASPState database. The advantage of this method is that the data is persisted even if you restart the SQL server. Custom storage: Both the session state data and the stored procedures are stored in a custom database. The database name must be specified in the configuration file.
The session data is stored in the application domain of the web server.
Found the issue.
When you create applications that you expect to share session state using Sql Server, they need the same ID configured in IIS. This is because the session ID that is generated is generated based on the application ID. (Internally the application ID is something like LM/W3SVC/1
The two servers had different IDs for each application in IIS. The resolution is to change the ID under `Manage Website -> Advanced Settings' on each server.
Review the IsolateApps modifier on the machine key element - http://msdn.microsoft.com/en-us/library/w8h3skw9%28v=vs.100%29.aspx
Did you recently upgrade from 3.5 to 4.0?
Last resort - recycle the appPools on both machines, and restart IIS.
Sessions have (web) application scope. See if this MS KB helps.
Update: Interesting down vote. Perhaps my suggestion needs more clarity.
In addition to matching machine keys, you also have to match the IIS configuration for sites (so it's the "same application" (application path) in IIS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With