ASP 应用对象


一组协同工作以执行某种目的的 ASP 文件称为应用程序。 Application 对象用于将这些文件连接在一起。


应用对象

Web 上的应用程序可能由多个 ASP 文件组成,这些文件协同工作以执行某些目的。 Application 对象用于将这些文件连接在一起。

Application 对象用于存储和访问任何页面的变量,就像 Session 对象一样。区别在于所有用户共享一个应用程序对象(对于会话,每个用户都有一个会话对象)。

Application 对象保存将由应用程序中的许多页面使用的信息(例如数据库连接信息)。可以从任何页面访问该信息。信息也可以在一处进行更改,更改将自动反映在所有页面上。

Application 对象的集合、方法和事件描述如下:

收藏

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

方法

Method Description
Contents.Remove Deletes an item from the Contents collection
Contents.RemoveAll() Deletes all items from the Contents collection
Lock Prevents other users from modifying the variables in the Application object
Unlock Enables other users to modify the variables in the Application object (after it has been locked using the Lock method)

活动

Event Description
Application_OnEnd Occurs when all user sessions are over, and the application ends
Application_OnStart Occurs before the first new session is created (when the Application object is first referenced)