Note that there are some explanatory texts on larger screens.

plurals
  1. POIsPostBack is false when transfering to different server in server farm?
    text
    copied!<p>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?</p> <p>Details:</p> <ol> <li><p>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.</p></li> <li><p>To further verify the keys and Id I printed out the values of <code>HttpRuntime.AppDomainAppId</code> and a hashed machinekey <code>(MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey")</code> and the sessionId <code>Session.SessionID</code> and got the same output on both servers. I used <a href="http://pardini.net/blog/2011/02/17/the-ultimate-asp-net-session-state-debugging-tool/" rel="nofollow noreferrer">Session Debug page</a> as a base for this. Its output looks something like this (I replaced my actual machinkey hash and session id with dummy values):</p> <pre><code>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 </code></pre></li> <li><p>The ID for the site, found in IISMgr under Advanced Settings on the site is the same on all servers.</p></li> <li><p>As long as I stay on the same server everything works as expected.</p></li> <li><p>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</p></li> <li><p>Stepping through the code and reading up on the <code>IsPostBack</code> property it seems my problem is that <code>this._fPageLayoutChanged</code> on the Page is true. However, if I understand things correctly it should be false when a postback happens? <a href="https://stackoverflow.com/questions/5650580/how-does-ispostback-technically-work">SO Question on its implementation</a></p></li> <li><p>Both servers run IIS 7.</p></li> <li><p>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. </p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload