Developing Web Applications

Previous Topic Next Topic

Declaring Objects in Global.asa

You can declare objects in Global.asa with session or application scope by using the extended <OBJECT> tag. This tag is placed outside of any <SCRIPT> tags. In addition to setting ID and ClassID parameters, you must set SCOPE (either “Session” or “Application”) and RUNAT=SERVER. This example creates an instance of the Page Counter component:

<OBJECT ID=GlobalPageCounter SCOPE=Application RUNAT=Server
   CLASSID="clsid:4B0BAE86-567A-11D0-9607-444553540000">
</OBJECT>

Having defined the GlobalPageCounter object in Global.asa, you can use it from any ASP file in your application without first retrieving it from the Application or Session object, or specifically calling Server.CreateObject first.

There have been <%= GlobalPageCounter.Hits("default") %> hits.

Note   The objects declared in Global.asa with <OBJECT> tags are not fully instantiated until the server processes a script that references that object. This saves resources by creating objects only as necessary.


© 1997-1999 Microsoft Corporation. All rights reserved.