ASP Application_OnStart en Application_OnEnd- gebeurtenissen


❮ Volledige referentie van toepassingsobject

Application_OnStart-evenement

De gebeurtenis Application_OnStart vindt plaats voordat de eerste nieuwe sessie wordt gemaakt (wanneer er voor het eerst naar het Application-object wordt verwezen).

Deze gebeurtenis wordt in het bestand Global.asa geplaatst.

Opmerking: Verwijzen naar een sessie-, verzoek- of antwoordobject in het Application_OnStart-gebeurtenisscript zal een fout veroorzaken. 

Application_OnEnd-evenement

De gebeurtenis Application_OnEnd vindt plaats wanneer de toepassing wordt beëindigd (wanneer de webserver stopt).

Deze gebeurtenis wordt in het bestand Global.asa geplaatst.

Opmerking: de MapPath-methode kan niet worden gebruikt in de Application_OnEnd-code.

Syntaxis

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

Sub Application_OnStart
. . .
End Sub

Sub Application_OnEnd
. . .
End Sub

</script>

Voorbeelden

Wereldwijd.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>

Om het aantal huidige bezoekers in een ASP-bestand weer te geven:

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

❮ Volledige referentie van toepassingsobject