Connecting Tech Pros Worldwide Help | Site Map

Master Page variables

prasans's Avatar
Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 17 '09
I have stored some of the variables used by lot of other pages of my website on the master page. As we are migrating to a load balanced environment, I want to know if I need to move those variables to a different place to make them still available even if the requests sent a different web server every time.

Had similar problems when I stored these variables in the session object and had to turn on SQLState to make them available in all web servers.

I am not too sure where the Master page object is stored.

Thanks
Prasanna
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#2: Sep 17 '09

re: Master Page variables


I'm not sure how you have got this to work but if you're able to store them in the MasterPage then you should not have a problem with Web Garden or Web Farm environments.

The reason you were having problems with session in this environment is probably because you were probably using InProc Session. This type of Session loads the variables into memory and keeps them there until the Session has expired. The problem with this is that they are loaded into memory on a particular server. If the user's request is sent to another server, then their session is not accessible.

If you still want to use Session you should consider using StateServer Session or SQLServer Session. Both of these types move the Session off of one particular server and into a centralized location so that all servers have access to it.

Check out Sessions - How To Pass Information Between Web Pages for more information.

-Frinny
prasans's Avatar
Newbie
 
Join Date: Sep 2009
Posts: 2
#3: Sep 18 '09

re: Master Page variables


Hi,

I turned on the SQLState and it works fine. (I had to remove the non-serializable items stored in the session though).

About storing the variables in the master page, it was quite simple. I created some variables in the master page and they were available in all the other pages. My guess is, these variables would also be stored in the application server memory and would cause a problem in the clustered environment. Anyways, I moved them to the session as I wasn't sure about the master page content scope.

Thanks
Prasanna
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#4: Sep 18 '09

re: Master Page variables


These variables could be stored in the ViewState in the master page. The problem I see with this is making them easily accessible to the content pages.
Reply

Tags
master page, shared variables, sqlstate