I have a asp.net website that is deployed on two servers. In front of the servers there's a load balancer that distribute requests to the two servers. To store the session we use SQL Server. My problem is that if the user go to the page, press a button and then by the load balancer happens to be routed to the other server that request wont be recognized as a postback? Why is that, shouldn't it work just fine even with postbacks as long as the servers share the same machine keys?
Details:
Both servers have the same machine key configured, and I verified that the actual session is the same on both servers by a small debug page I made that sets and prints out a session object.
To further verify the keys and Id I printed out the values of
HttpRuntime.AppDomainAppId
and a hashed machinekey(MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey")
and the sessionIdSession.SessionID
and got the same output on both servers. I used Session Debug page as a base for this. Its output looks something like this (I replaced my actual machinkey hash and session id with dummy values):Current DataTime: 2012-07-20 10:52:58 Current Session Mode: SQLServer HttpRuntime.AppDomainAppId: /LM/W3SVC/5/ROOT Hashed with the MachineKey: HjtOPW5dfoihdlkd+SdsfkEWfs0= Local Machine Name: 127.0.0.1 Current Session ID: 2alsudhsdkjlhcmnsdfkhsdf
The ID for the site, found in IISMgr under Advanced Settings on the site is the same on all servers.
As long as I stay on the same server everything works as expected.
When I run the page locally (first request to web farm, then route second button click to localhost by fiddler), I get the same behaviour
Stepping through the code and reading up on the
IsPostBack
property it seems my problem is thatthis._fPageLayoutChanged
on the Page is true. However, if I understand things correctly it should be false when a postback happens? SO Question on its implementationBoth servers run IIS 7.
Both servers run Windows Server Web with SP2 and the same windows update updates installed. My local dev machine on the other hand runs Windows 7.