Home page   WebCheatSheet.com


ASP Application Object


An Active Server Page application is actually a collection of ASP files in a virtual directory and associated sub-directories. The Application object is used to control and manage all items that are available to all users of an Active Server application. The Application items can be variables needed for all users in the application, or they can be instantiated objects that provide special server-side functionality.

The Application object is initialized by IIS when the first .asp page from within the given virtual directory is requested. It remains in the server's memory until either the web service is stopped or the application is explicitly unloaded from the web server (using the Microsoft Management Console).

The syntax, collections, methods and events of the ASP Application object are as follows:

Syntax

Application.method

Collections

Collections Description
Contents The Contents collection contains all the items added to the application through the use of scripts (not through the use of the <OBJECT> tag).
StaticObjects The StaticObjects collection contains all session-level objects added to the application through the use of the <OBJECT> tag. The collection can be used to retrieve the value of a specific property for an object, or to retrieve all properties for all static objects.

Methods

Methods Description
Contents.Remove The Contents.Remove method deletes the specified item from the Application object Contents collection.
Contents.RemoveAll The Contents.RemoveAll method deletes all the items from the Application object Contents collection.
Lock The Lock method locks the Application Object, preventing other users from modifying the same application-level variables at the same time. The individual user retains control of the Application object until the Application.UnLock method is declared. If the Unlock method is not called explicitly, IIS will unlock the locked Application object when the script ends or times out.
Unlock The Unlock method releases control of the locked application variables. Once Unlock has been called, other clients can again alter the values of the variables in the Application object. If the Unlock method is not called explicitly, IIS will unlock the locked Application object when the script ends or times out.

Events

Events Description
Application_OnStart The Application_OnStart event occurs before the first new session is created (when the first client request is received).
Application_OnEnd The Application_OnEnd event occurs when the ASP application is explicitly unloaded from the web server or when the web service on the web server is stopped.



Copyright © 2005-2007 www.WebCheatSheet.com All Rights Reserved.