Latest web development tutorials

ASP Application_OnStart et événement Application_OnEnd

Application Object Reference Complete Application Object Reference

événement Application_OnStart

événement Application_OnStart se produit avant la première nouvelle session est créée (lorsque l'objet de l'application est d'abord référencé).

Cet événement est placé dans le fichier Global.asa.

Note: Lors du référencement Session, Demander ou objet Response Application_OnStart script d'événement renvoie une erreur.

événement Application_OnEnd

Application_OnEnd événement se produit à la fin de l'application (lorsque le serveur est en panne).

Cet événement est placé dans le fichier Global.asa.

Note: méthode MapPathne peut pas être utilisé le code Application_OnEnd.

grammaire

<script language="vbscript" runat="server">

Sub Application_OnStart
. . .
End Sub

Sub Application_OnEnd
. . .
End Sub

</script>


Exemples

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>

fichier ASP est affiché dans le nombre actuel de visiteurs:

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


Application Object Reference Complete Application Object Reference