Open In App

ASP Application_OnStart Event

Improve
Improve
Like Article
Like
Save
Share
Report

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 defines 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>


Last Updated : 16 Dec, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads