当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP Application_OnStart 与 App

ASP
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP 摘要
ASP 实例

ASP Application_OnStart 与 App


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 416 ::
收藏到网摘: n/a

Application_OnStart Event
Application_OnStart 事件

The Application_OnStart event occurs before the first new session is created (when the Application object is first referenced).
Application_OnStart 事件在第一个新的session建立之前产生(当Application对象被第一次引用时)。

This event is placed in the Global.asa file.
该事件是写在Global.asa文件中的。

Note: Referencing to a Session, Request, or Response objects in the Application_OnStart event script will cause an error. 
注意:直接在Application_OnStart事件中引用Session、Request、Response对象将会导致错误产生。

Application_OnEnd Event
Application_OnEnd 事件

The Application_OnEnd event occurs when the application ends (when the web server stops).
Application_OnEnd事件在application结束后产生(当网络服务器停止时)。

This event is placed in the Global.asa file.
该事件是写在Global.asa文件中的。

Note: The MapPath method cannot be used in the Application_OnEnd code.
注意:绝对路径(MapPath)方法不能在Application_OnEnd代码中使用。

Syntax
语法

<script language="vbscript" runat="server">
Sub Application_OnStart
. . .
End Sub
Sub Application_OnEnd
. . .
End Sub
</script>

Examples
举例

Global.asa:
<script language="vbscript" runat="server">
Sub Application_OnEnd()
Application("totvisitors")=Application("visitors")
End Sub
Sub Application_OnStart
Application("visitors")=0
End Sub
Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>

To display the number of current visitors in an ASP file:

<html>
<head>
</head>
<body>
<p>
There are <%response.write(Application("visitors"))%>
online now!
</p>
</body>
</html>

评论 (0) All

登陆 | 还没注册?