By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

Session state with load balancing

P: n/a
In Web.config file is a setting for sessionState. If I
want to maintain a users' session state (ie use the
Session object) in a web farm that is being load balanced
by a Cisco CSS 11501 Switch. How do I setup sessionState
so anything saved to the Session object stays with that
session no matter what web server they get bounced around
to?
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Robert

I think what you really want to do is provide Session state that supports load balancing. This is better than trying to maintain server-adherence since that sort of defeats the purpose of load balancing

There are two ways to do this, one is to use a "StateServer" service. This is very easy to do, just pick a machine to be your state server and point all the machines on your farm to that server in the session cofniguration

The other way is to use SQLServer session state. This stores all of the state information in a SQL server of your choosing. This is my personal preference because our SQL Servers have a fail over strategy that will ensure that the farm is never down, where if yo use the state server method you are relying on a single machine being up and running, and if it goes down your farm dies

There are a couple things you will want to pay careful attention to when setting up farm session state

1. Make sure you have the same MachineKey configured in your machine.config file on all machines on the farm. The reason for this is that the view state (stored on the client) is encrypted using the machine key of the server that served the page. If you bounce between two or machines within a single session you will get an error that you have an invalid view state

2. Double check all of your application config files. By default, Visual Studio.NET will create a web.config for each ASP.NET project you create. The settings in this file default to InProcess session state. This will cause problems because this setting will override the setting in your machine.config and you will be ripping your hair out. The easiest thing to do is to just delete the web.config file entirely if you are not using it, or if you are using it, delete the Session configuration block from it so that your web application uses the default you conifugred in the machine.config

I hope this helps, if you need more help or examples, just let me know

Thanks
-Cla

Clayton Gulick, MCSD
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.