views:

45

answers:

2

Ran into this issue yesterday on one of our sites. First of all the site is hosted in a web farm environment and for the time being I have added a static machineKey to the web.config on both nodes (2 node environment). This has solved the issue and everything is running fine now.

This raised the following question: Why is it that all our other sites that run on this environment does not require this (machineKey in the web.config).

I checked event logs to make sure that we are not having the same issue on other sites and everything looks fine. I also confirmed that the app pool is not recycling too often and everything was normal with regards to app pool settings.

The only explanation I can come up with is that the site is rendered by one node and subsequent post backs go to another node - which would leave me to believe that the problem lies with the load balancer. Our infrastructure guys tells me that everything is as it should be with regards to the load balancer and the scenario that I am proposing will not happen.

Am I missing the obvious here or are there anything else that I can consider?

Thanks in advance

A: 

If you are working with a web-farm environment, machine key values, if specified in the web.config need to be synced. In addition, you will want to make sure that the machine key values in the machine.config file are also synced between the two.

Mitchel Sellers
@Mitchel I understand the logic behind that but what I don't get is why other sites seem to work fine without having a machine key value specified in the web.config and if the machine.config is synced between nodes and that is the reason why the other sites work, why do we have site needing it specified on the web.config as well.
Dieter G
+1  A: 

Basically, yes, you're right - you generally see this in a web farm environment when "Sticky Sessions" aren't properly configured in the load balancer, and the users postback is sent to a different server.

To be fair to your network guys, it's possible that most requests are being sent to one server, but that this application is tipping the usage such that requests are often sent to another server - but you should be seeing that across all sites, unless the traffic patterns are completely different.

The other possible cause is that either your page is taking too long to load, and the users are posting back before the page has completely finished loading - I'd managed to get one of my sites doing that with a couple of remote advert calls buried halfway through the page load, or the users are waiting too long between page render and postback and the session on the loadbalancer is timing out so it thinks it's a new request.

Zhaph - Ben Duguid
+1 for the Sticky Sessions idea - I am having the network guys check how session persistence is configured for this particular site. I doubt very much that the page is loading too slow or not loaded completely before a post back happens - its a one page "registration of interest" type site with a few textbox fields and no heavy graphics (using CSS sprites to reduce http requests and total image size)
Dieter G
Session Persistence or "Sticky Sessions" was set to 0 seconds on the load balancer so requests were flicked between servers based on traffic load. Explains why our other sites ran fine without a static machineKey defined in the web.config because they stuck to a single node - Thanks for the advice.
Dieter G
No problem, I've made similar mistakes myself ;)
Zhaph - Ben Duguid