Open In App

ASP Application_OnStart Event

The ASP Application_OnStart Event occurs before the beginning of the new session created by the user.It occurs before the Application object referenced. This event will be  placed in the Global.asa file.The Application_OnStart event script causes an error when e. Referencing the Session Object, Request Object, or Response Object objects.

Syntax: 



<SCRIPT LANGUAGE=ScriptLanguage RUNAT=Server>
Sub Application_OnStart. . . End Sub
</SCRIPT>

Parameter Values  

Example Code:  Below code used to display the number of visitors in an ASP File. 



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>

HTML FILE  

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

</html>

Article Tags :