Monday, May 26, 2008

Global.asa File

The Global.asa file is an optional file (stored in the root directory of the application) that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application.

The Global.asa file can contain only the following:

Application events
Session events
object declarations
TypeLibrary declarations
the #include directive

Events in Global.asa
Application_OnStart: Occurs when
# The FIRST user calls the first page from an ASP application.
# after the Web server is restarted or after the Global.asa file is edited
Session_OnStart: Occurs
# EVERY time a NEW user requests his or her first page in the ASP application.
Session_OnEnd: Occurs
# EVERY time a user ends a session.
# after a page has not been requested by the user for a specified time
Application_OnEnd: Occurs
# after the LAST user has ended the session.
# when a Web server stops

Note: we cannot use the ASP script delimiters to insert scripts in the Global.asa file


A Global.asa file could look something like this:



Difference between Object tag and Server.CreateObject:
object tag creates the object and initializes the memory only when the first method/property of the object was accessed.Server.CreateObject will immediately create the object and initialize the memory.


No comments: