How can we change session state of a website from one state to another

1.5k views Asked by At

Basically my question is i have a website which was developed around 3 years ago, while development it was proposed that this site will be used by few people on internet.

But now it seems like many users are accessing the website. So we have planned to create a Web sever Farm where we have multiple servers for our website.

major problem in development is old website used InProc Session state and now since we are upgrading to multiple servers we want to change InProc to Outproc i.e StateServer Session State.

Can you guide me on this upgrade and how can it be achieved in simple and easy way rather than changing the coding on each pages wherever sessions are used.

1

There are 1 answers

3
Aristos On BEST ANSWER

What you going to have here is that you move your site to many web servers and the actual issue here is "how to keep the same state for each user regarding the server".

There are two options.

First option is to setup the router that split the users to the server, to use the "Sticky option", meaning that each user is stick for his session to one server, and one only. In this case it did not matter if you use inproc or sql server session, as long as the router make good job. This is the case of course that you do not use any other database for common data.

Second option is to use an sql server and move the session to the server, but here the server must be on one server and the others server's gets his session data from this one. Also you setup on web.config the same key machine for all web servers.

So for this case you need.

  1. To setup a common/shared SQL server on one server
  2. To install on this the session database (actually run a script from asp.net)
  3. Setup the web.config to use this database as session
  4. Setup the web.config to have the same machine key.

In the case that you use a database for other data, then you place this database together with the session database, and you make a share connect to that database also. The point here is that the data must be live on one computer, and the other computers connect to this main one for the data.