Actually, the static variables don't apply to the application, they
apply to the whole app-domain, which the Application is just a part of.
Each web app on IIS runs in its own application domain. Granted, there is
only one Application object per web app, but it is an important distinction,
because static variables are tied to one, and not the other.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"boxim" <sa*********@yahoo.co.uk> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Yes, they're common across the application. (not Session)
I've just done exactly the same thing
got a class with static members that are used in classes not derived from
Web.UI.Page
also contain Session specific stuff in instance variables
i.e.
class mystateclass {
protected string _username;
public static string DatabaseServer {
get {
// gets from config file
}
}
public string CurrentUsername {
get {
return _username;
}
}
///////
// in Session_Start
Session["stateinfo"] = new mystateclass();
HTH
sam
"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:Oq****************@tk2msftngp13.phx.gbl... I am using C# to program ASP.NET. I am using class of static fields to hold all variables that are common to the application, and I am sure that
this is fine. However, I was also using some static fields to hold values that
calculated every time a user opens a page (unique to each session).
These static fields are used in other classes thoughout the application.
However, it suddenlly struck me that these static fields are (i think) common
across all user sessions so that they may confict when two(or more) users try
to open a page that sets and accesses these fields at the same time. Is
that correct?
I am thinking that I should be using instance field variables for all
variables where the data is unique to that session? Is that correct?
Thanks for the help
Earl