Hi

We have two identical web servers in a farm and I need them to be able to share Session variables as I do not know which machine the user will be using at any given time i.e. if a user where to log in to a site on server1 and then post back I cannot 100% guarentee that server 1 will process the request.

I have been looking at sharing session state through SQL but rather than do this on our live servers I set up a pair of VM's on my local machine to test. I have SQL (2005 Developer edition) installed locally on my machine so I decided to use this as my test DB.

On each machine, I posted up a test web site with a default page to enter some text (firstname and lastname) and then store these in a class which I have marked as serializable and store this class in a session variable.

On the Web config of the site(s), I have carried out the following:

  1. Set a common Machine Key to allow session state to be shared accross both servers
  2. set enableViewStateMac to false
  3. Set Session State mode to SQLServer
  4. Added a SQL connection string to my local DB with a specified SQL login
  5. Set Cookieless to use cookies
<machineKey validationKey="#######################" decryptionKey ="~~~~~~~~~~~"  validation="SHA1" decryption="AES" />
<enableViewStateMac ="false" />
<sessionState mode="SQLServer" sqlConnectionString="server=<myServer>;uid=<SQLUser>;pwd=<Password>" cookieless="UseCookies" timeout="20" />

I ran the ASPNet_Regsql.exe on My database server with the -ssadd switch and the -t switch under my local user account -E

I then gave the user I'm using to connect to the Database execute permission on all the Stored proceudres in the ASPState Database and also INSERT, SELECT, UPDATE and DELETE permission on the tables set up in the tempdb database.

Finally on each of the local servers, I edited the IIS metabase to ensure both sites were on the same local path LM/W3SVC/################# and restarted the IIS service.

When I connect on the site on Server 1, I enter my details and submit this goes through to the next page and shows me the session variable details. - no issue

I then change the IP in the Url of my browser to that of the other server and open but when I get that page open the session variable has gone. If I switch back to the first server (again just mod the IP address in the browser link) everything is there.

Any one know what I'm missing?

Anyone??

No idea..I think just search on Google with machine.config file.
I think it is related to that

No idea..I think just search on Google with machine.config file.
I think it is related to that

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.