ASP » Application » OnEnd

The OnEnd event occurs when the Application quits. This should not occur unless all user sessions are over. The signal of this event will run a handler script in the Global.asa file, if the script exist.

The Application_OnEnd event occurs when the Application ends. This should only happen when the web server is stopped by the operating system in a normal manner. The Application_OnEnd event is simply a subroutine with a reserved name that is placed within the Global.asa file. It can contain any script that you wish to run after all user sessions are finished. For example, you may wish to compute and store statistics on user sessions for future reference.
 
Note: The only built-in ASP objects available from within the OnEnd event handler are Server and Application.

Examples

Code:
-------------------Global.asa--------------------------
<script Language="VBScript" RUNAT=Server>
Sub Application_OnEnd()
     Calculate_Stats()
End Sub

Sub Application_OnStart()
     Application("NumSession") = 0
     Application("NumVisited") = 0
End Sub

Sub Session_OnEnd()
     Application("NumSession") = Application("NumSession") - 1
End Sub

Sub Session_OnStart()
     Application("NumSession") = Application("NumSession") + 1
     Application("NumVisited") = Application("NumVisited") + 1
End Sub 
</script>

-------------------File1.asp----------------------------
Response.Write "You are " & Application("NumSession") & " of " & Application("NumVisited") & " users."

See Also: