ASP Application Object

A group of ASP files that work together to complete a task is called an application. The role of the Application object in ASP is to bind these files together.

Application object

A web application can be a group of ASP files. These ASP files work together to complete a task. The role of the Application object in ASP is to bind these files together.

The Application object is used to store and access variables from any page, similar to the Session object. The difference is that all users share one Application object, while the session object is one-to-one corresponding with users.

The information that the Application object holds is used by many pages in the application (such as database connection information). This means that we can access this information from any page. It also means that you can change this information on one page, and these changes will automatically reflect on all pages.

The following describes the collection, methods, and events of the Application object:

Collection

Collection Description
Contents Contains all items appended to the application through script commands.
StaticObjects Contains all objects appended to the application using the <object> tag with HTML.

Method

Method Description
Contents.Remove Remove an item from the Contents collection.
Contents.RemoveAll() Remove all items from the Contents collection.
Lock Prevent other users from modifying variables in the Application object.
Unlock Allow other users to modify variables in the Application object (after being locked by the Lock method).

Event

Event Description
Application_OnEnd This event occurs when all users' sessions have ended and the application is terminated.
Application_OnStart This event occurs before the first new session is created (at this time the Application object is referenced for the first time).