views:

287

answers:

2

Hi,

I am creating an ASP.NET page where I need a couple of variables which hold pathnames and a chosen language etc... Not that many, let's say about 5.

Should I use session variables for this? Atm I'm using public static variables but I'm not sure if this is the right way to do this.

Any thoughts?

Thx

+4  A: 

Public static variables are definitely not the correct way of doing this because they will likely be shared between all your users. There's a multitude of ways of storing values. Session state, viewstate, hidden fields, profiles in a database, et cetera... it all depends on what kind of scoping you need for your data.

Matti Virkkunen
ah i see, seems like i misunderstood. Using session variables now
WtFudgE
will modify it later in storing through cookies or something
WtFudgE
+1  A: 

Based on your description, there is no such thing as global variables, because it seems that each user seems to chose his own language, therefore you need to chose one of Matti Virkkunen's suggestions.

If you really need a thing such as a global variable for all users, you should prefer the Application State over static variables.

citronas