Session state lost in asp.net web farm

I have been doing this for several months now.

I currently have 2 servers for 1 website. Using round robin dns, I found that everything works in the beginning (checking the ip of the site that he changed, but I can continue the session), but after a while I lose the session, it looks like cookies of the form cannot be read and are discarded. (assumption) But this does not happen all the time. Only sometimes.

I use the general iis7 configuration, I install the machine key, and I use the stateerver pointing to one of the servers, and I checked that the state server is running on both servers.

I read something about the IIS application path, but I really donโ€™t know what is meant by this, is this the path to Webapp or the path where IIS is installed? In both cases they are the same.

Does anyone have any ideas?

+4
source share
2 answers

I will answer it myself, for those who are facing the same problem. Everything was configured correctly, but the machine key should be located in the web.config file in the system.web file. For some reason, key generation via iis 7 did not work, I generated it using the online tool: http://aspnetresources.com/tools/machineKey

So, to perform load balancing and configure multiple servers on iis7, you must:

  • Use out-proc (stateerver or sql server) from stateerver state and all servers point to this state server (example: stateConnectionString = "tcpip = server1: 42424")
  • Use the iis shared configuration so that all your servers point to the shared resource where applicationhost.config is located.
  • Create a machine key (not via iis, just use the online tool!)
  • Configure NLB (or round robin DNS) and verify it by resetting your clientโ€™s DNS when you are logged in and see if your session is lost.

Hope this helps someone.

+2
source

And machine keys belong to the .NET version. To check the current version: on the server-side IIS console, click Change .NET Framework Version in the Actions panel.

0
source

All Articles