[ADVANCED-DOTNET] Global.asax: versus static variables

Tue, 20 Dec 2005 06:25:56 -0800

Hello,

I was used to specifiy global objects int the <object> tag in a global.asa
file.

It is still possible to do so in the dotnet environment, but I think its a
pain to do so, because you need a lot of casts and the way you access those
global objects is rather verbose. Its something like

    MyObject obj =
(MyObject)context.Application.StaticObjects.GetObject("MyObject");

It is also possible to declare only static variables in a class, and use
them instead of the <object> tag.
One can think of

public class MyGlobals
{
   public static MyObject myObject = new MyObject();
}

and then in a ashx or aspx file:
   MyGlobals.MyObject......

However, I'm not sure what the consequences are.
Can anybody explain what the exact difference is (I mean differences with
respect to threading, instacing, etc)

Thanks a lot.

Peter

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to