3

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:

  1. 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.

  2. 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 sessionId Session.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
    
  3. The ID for the site, found in IISMgr under Advanced Settings on the site is the same on all servers.

  4. As long as I stay on the same server everything works as expected.

  5. 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

  6. Stepping through the code and reading up on the IsPostBack property it seems my problem is that this._fPageLayoutChanged on the Page is true. However, if I understand things correctly it should be false when a postback happens? SO Question on its implementation

  7. Both servers run IIS 7.

  8. 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.

Community
  • 1
  • 1
viblo
  • 4,159
  • 4
  • 20
  • 28

1 Answers1

0

Turns out that adding a manual entry of the Machinekey in the web.config fixed the problem. Very strange as I checked its global value and also the hash as detailed in the question but now it works.

I take that back. After our last release the problem is back, so the machinekey addition did not help at all.

viblo
  • 4,159
  • 4
  • 20
  • 28