The ASP Application object is used to share information between all the users of a particular ASP application. All ASP files under one virtual directory in IIS are part of one and the same ASP application.
The Application.Contents collection contains all of the items that have been added to the ASP Application object with ASP scripting commands.
The Application.StaticObjects collection contains all of the objects that have been added to the ASP Application object with the <OBJECT> tag.
You can store variables into the Application.Contents collection in the following manner:
Application(“TotalApplicationUsers”) = 255
You can read and display a variable stored in the Application object, with the following ASP code:
Response.Write Application(“TotalApplicationUsers”)
Always remember that the Application object is shared between all users of the ASP application.
The 2 main ASP Application object methods are Application.Lock and Application.Unlock. The ASP Application object is shared between all ASP application users, that’s why the Application.Lock and Application.Unlock methods guarantee that no more than one user can change a variable stored in the Application object in any given moment.
Here is how to use Application.Lock and Application.Unlock methods to change a variable stored in the Application object:
Application.Lock
Application(“TotalApplicationUsers”) = Application(“TotalApplicationUsers”) + 1
Application.Unlock
|