当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP Application
A group of ASP files that work together to perform some purpose is called an application. The Application object in ASP is used to tie these files together.
我们把通过协同工作来实现一些功能的一组ASP文件称为一个Application。ASP文件中的Application对象是用来把所有的这些文件绑定在一起的。
An application on the Web may be a group of ASP files. The ASP files work together to perform some purpose. The Application object in ASP is used to tie these files together.
在网页中的Application可以是一组ASP文件。这些ASP文件在一起协同工作共同实现一些功能。ASP文件中的Application对象是用来把所有的这些文件绑定在一起的。
The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share one Application object, while with Sessions there is one Session object for EACH user.
Application对象是用来存储和访问页面中的变量的(范围是所有页面),这个类似于Session对象的功能。他们的不同点在于Application对象可以被所有的用户访问,而Session对象则只能被单个的用户访问。
The Application object should hold information that will be used by many pages in the application (like database connection information). This means that you can access the information from any page. It also means that you can change the information in one place and the changes will automatically be reflected on all pages.
如果有的信息(一般是通用信息,如:数据库连接信息)是需要被所有的页面访问的,那么,可以使用Application对象。这意味着你可以访问到来自于任何页面的信息;同时,它也意味着:如果你改变了一个地方的信息,那么所有页面中的信息都会随之改变。
The Application object's collections, methods, and events are described below:
Application对象的集合、使用方法以及事件属性将通过下面的表格进行描述。
Collection 集合 | Description 描述 |
---|---|
Contents | Contains all the items appended to the application through a script command 包括所有通过脚本命令添加到Application中的项目 |
StaticObjects | Contains all the objects appended to the application with the HTML <object> tag 包括所有通过HTML<object>标签添加到Application中的对象 |
Method 方法 | Description 描述 |
---|---|
Contents.Remove | Deletes an item from the Contents collection 从Application Contents集合里删除其中一个项目 |
Contents.RemoveAll() | Deletes all items from the Contents collection 删除Application Contents集合里的所有项目 |
Lock | Prevents other users from modifying the variables in the Application object 给Application对象上锁以防止其他用户修改Application对象中的值 |
Unlock | Enables other users to modify the variables in the Application object (after it has been locked using the Lock method) 给Application对象解锁,以保证用户能够对Application对象中的值进行修改 (在Application对象被上锁后进行解锁) |
Event 事件 | Description 描述 |
---|---|
Application_OnEnd | Occurs when all user sessions are over, and the application ends 在所有用户的Session(会话程序)和Application(请求程序)结束时执行 |
Application_OnStart | Occurs before the first new session is created (when the Application object is first referenced) 在第一个新的Session(会话程序)建立之前执行 (当Application对象第一次被访问时) |