Skip to content
Related Articles

Related Articles

Improve Article

ASP Application_OnStart Event

  • Last Updated : 01 Feb, 2021

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  

  • ScriptLanguage: It defjnes the Language of the script which is used to write a event script.It supported different scripting language, such as VBScript or JScript.

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>

My Personal Notes arrow_drop_up
Recommended Articles
Page :