I. Overview of Application objects
When loading an ASP DLL and responding to the first request for an ASP Web page, create the Application object. This object provides a storage place to store variables and objects that are available to all Web pages that are open to all visitors
You can use the Application object to share information between all users of a given application. An ASP based application is defined in a virtual directory and its subdirectories, as with all. asp files. Because multiple users can share application objects, there must be a Lock and Unlock method to ensure that multiple users cannot change a property at the same time.
Application objects are used primarily for:
1 statistics of the number of visitors to the website;
2) Statistics of the number of clicks;
3) Create chat room;
4 Read the data in the database and so on.
The syntax format of the Application object is as follows:
Application 集合 | 方法
Second, the Session object collection
The Application object provides two collections that can be used to access variables and objects stored in the global application space. As shown in Table I:
Table I
| Collection |
Meaning |
| Contents |
Contains items that have been added to the application with script commands, Contents is the default collection of application objects. |
| StaticObjects |
Contains objects created with the object tag and given the scope of the application. |
Three, Application object method
Table II
| Method |
Meaning |
| Contents.Remove |
Deletes an item from the contents collection of the Application object. |
| Contents.RemoveAll |
Deletes all items from the contents collection of the Application object. |
| Lock |
Prevents other users from modifying the Application object's variables. |
| Unlock |
Allow other users to modify the Application object's variables. |
Iv. Application object events, such as Table III:
Table III
| Event |
Meaning |
| Application_OnStart |
Triggered when ASP starts, before the Web page that the user requests is executed and before any user creates the Session object. Used to initialize variables, create objects, or run other code. |
| Application_OnEnd |
Triggered when an ASP application is finished. Occurs after the last user session has ended and all the code in the OnEnd event of the session has been executed. When it ends, all variables present in the application are canceled. |
See the full set of ASP Getting started tutorials