ONE Active Server Pages Product Home Page Developer Site Version


ASP Application Object Events

ASP Application object events are listed in the following table.

Runs when an ASP page belonging to the application is accessed for the first time.
Runs when the Web server is shut down on Windows, and when the ASP Server is shut down on UNIX and Linux.

Values can be stored in the Application object. These values are available throughout the application and have application scope.

Objects can be created within the Application_OnStart script and assigned to the Application object. You cannot, however, store a built-in object in the Application object. Each of the following lines will return an error:

Set Application("var1") = Session
Set Application("var2") = Request
Set Application("var3") = Response
Set Application("var4") = Server
Set Application("var5") = Application

Before you store an object in the Application object, you must know what threading model it uses. Only objects marked as both free and apartment-threaded can be stored in the Application object.

The Application object is implemented as a collection. If you store an array in an Application object, you should not attempt to alter elements of the stored array directly. For example, the following script does not work:

Application("StoredArray") (3) = "new value"

Instead of storing the value "new value" in StoredArray(3) the value is stored in the Application collection, overwriting any information stored at Application(3).

Note icon Note If you store an array in the Application object, it is strongly recommended that you retrieve a copy of the array before retrieving or changing any elements of the array. When you are done making changes to the array, store the array back into the Application object to save changes. This is demonstrated in the following examples.