Statics vs. Session Variables

After migrating your applications to Wisej.NET you need to inspect all your static variables. By default statics are shared among all applications in the same AppDomain (Application Pool in IIS).

Some of the statics that are global lookups (like a list of countries or languages or currencies) and independent from a user, can stay static.

Most statics must now become session variables. Variables stored in the Application.Session object are visible only to a single user/session. The session object is a dynamic object and can be used as if the variables were its members.

Sample usage:

// Session is a dynamic object
Application.Session.MyVar1 = 1;
Application.Session.MyVar2 = “Test”;
// Statics moved to session
MyClass.Static1 = “Hello”;
// Becomes
Statics.MyClass.Static1 = “Hello”;
// It’s an easy search/replace.
Statics {
	MyClass { get {
		return Application.Session.MyClass; }}}

Last updated