2

I've been given the task of looking into a problem where the session of a user changes between refreshes of a page. Immediately (not knowing anything about the website) I said that it seems like a load-balancing/web cluster configuration issue. However, I found out later that the website is not load-balanced - It's a single server.

The application has a Basket object which is stored in Session. The user adds items to the basket etc. When on the basket page, if the page is refreshed the items which are in the basket change and sometimes there are none.

The session is not lost, it comes back almost always on the next refresh but then the basket can be empty or have different content on the next refresh. I've seen this behaviour before many times but only on multi-server set-ups.

This is something we have tried to replicate on a developer environment with no success - we simply cannot replicate the problem but on live it happens a lot.

The web application is an ASP.NET WebForms site, running under .NET 4.0 on Windows Server 2008 R2 and IIS 7.5.

Session state mode is InProc and the session timeout is set to 480 minutes.

I've used fiddler to look at the requests and responses and the ASP.NET session ID passed to the server is the same each time. There appears to be no difference between the responses besides the actual HTML returned.

Has anyone got any ideas on what could cause this problem?

Update 1:

I have re-worked some of the logging that a colleague implemented in the basket code. I can now see that the Session ID remains the same, the value of the Session variable also stays the same even though different data is displayed.

Sorry, I should have checked their logging before posting this.

I'm convinced that this is a server issue though, the code works as expected in our testing environment.

2
  • Is teh ASP Session state service disabled? it should be if you don't load balance/HA, and it could be confusing things. Are you sure that the items change, and don't simply disappear? Session timeout could explain how the basket empties on reload or navigate, but would definitly not explain how new items appeared in it. Are you using cookies for authentication persistence? – Frank Thomas May 16 '14 at 15:17
  • Thanks for the comment. Session is InProc and the data actually remains the same (see update above) but this has only become apparent to me now. It's a very strange problem. – James May 16 '14 at 15:57
0

"I said that it seems like a load-balancing/web cluster configuration issue. However, I found out later that the website is not load-balanced - It's a single server."

Just because it's a single server doesn't mean there's not load balancing going on. IIS has within it a feature called a "Web Garden" which splits the web work across more than one process, so that it can be spread across multiple CPUs.

It's like a small "Web Farm" -- hence the name "Web Garden". :)

An effect when using a Web Garden is that it makes InProc session variables stop working correctly, as you may end up in a different worker process on each page request. InProc (In Process) only works reliably if you always end up in the same Process.

Solution 1:

  • Ensure IIS isn't set to use a Web Garden. To do this:
    1. Open IIS manager.
    2. Determine which App Pool you web app is using.
    3. Right-click your App Pool and select "Advanced Properties".
    4. Scroll down and set "Maximum Worker Processes" to 1.

App Pool Settings

Solution 2:

Check out this MSDN blog: In-Proc Session State Management

It describes your session state options, and how to troubleshoot InProc session loss.

2
  • Thanks a lot for the response. I already checked the worker processes, it's set to 1. As for Session server, that's a possibility but given my latest findings (updated above) it might be pointless. – James May 16 '14 at 15:55
  • Let this be a lesson; always check and test things yourself. Worker processes was the problem - something I said to check 5 days ago and was assured it was set to 1. Thanks! – James May 19 '14 at 13:39
-1

I have not changed the code for a long time.(last change : 20 July 2016)

But I have too same problem in Windows Server 2016. My customer was upgrade windows 2012 R2 to windows 2016. I couldnt solve this problem.

Then I downgrade to old server (windows 2012 r2). My problem was solved. I think it is a bug but i cant be sure

Maybe it will help you.

2
  • 1
    Did you do any troubleshooting/research about what about the upgrade could have caused the issue? As your situation isn't completely similar to the asker's, some pointers on how you diagnosed the issue might help. – iwaseatenbyagrue Mar 28 '17 at 8:20
  • Yesterday, I experienced the same problem again on old server (windows 2012 r2). I changed sessionstate configuration today. maybe help anyone : search RegenerateExpiredSessionId – ehocam Apr 6 '17 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.