网络学院 w3pop社区 网络资源 IT新闻

w3pop.com :: 网络学院 :: ASP :: ASP Application_OnStart 与 App

会员登陆

帐号

密码

回答

记住密码

忘记密码? 注册

ASP Application_OnStart 与 App


作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-28 浏览:1371 :: ::

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