This article mainly introduces the techniques and usage of Global.asa files in ASP. Global.asa files can manage two very demanding objects in ASP applications: Application and Session. Friends who are interested in this aspect can refer to it.
We all know that .asa is the file suffix name. It is the acronym for Active Server Application.
It is actually an optional file in which the program writer can specify event scripts and declare objects with session and application scopes. The contents of this file are not used to display to the user, but to store event information and objects used globally by the application. This file must be stored in the root directory of the application. Each application can only have one Global.asa file.
The most common misconception about Global.asa files is that it can be used as a library for general use functions and subroutines. The Global.asa file can only be used to create references and capture startups of objects, as well as end Application objects and Session objects.
The Global.asa file is accessed based on session-level events and is called in the following three cases:
The standard file format of Global.asa is as follows:
?
- <SCRIPTLANGUAGE=VBScriptRUNAT=Server>
- SubApplication_OnStart
- 'Application_OnStart runs when any customer first accesses the homepage of the application
- EndSub
- SubSession_OnStart
- 'Session_OnStart Runs when the client first runs any page in the ASP application
- EndSub
- SubSession_OnEnd
- 'Session_OnEnd runs when a client's session timed out or exits the application
- EndSub
- SubApplication_OnEnd
- 'Application_OnEnd runs when the site's WEB server is down
- EndSub
- </SCRIPT>