Detailed introduction to the Global.asa file in ASP

Y2J
Release: 2017-05-19 10:55:30
Original
1474 people have browsed it

The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application.

Global.asa file

The Global.asa file is an optional file that contains information that can be accessed by every page in an ASP application. Declaration of objects, variables, and methods. All legal browser scripts can be used in Global.asa.

The Global.asa file can contain the following:

Application event

Session event

Statement

TypeLibrary declaration

#include directive

Note: The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa document.

Events in Global.asa

In Global.asa, we can tell the application and session objects what to do when starting and ending. The code to accomplish this task is placed in the event operator. The Global.asa file can contain four types of events:

Application_OnStart - This event occurs when the first user calls the first page from an ASP application. This event occurs after the web server is restarted or the Global.asa file is edited. The "Session_OnStart" event occurs immediately after this event.

Session_OnStart - This event occurs every time a new user requests his or her first page in an ASP application.

Session_OnEnd - This event occurs whenever the user ends the session. If no page is requested within the specified time (the default event is 20 minutes), the session will end.

Application_OnEnd - This event occurs after the last user ends their session. Typically, this event occurs when the web server is stopped. This subroutine is used to clear settings after the application is stopped, such as deleting records or writing information to a text file.

Global.asa file may look like this:

<script language="vbscript" runat="server">
sub Application_OnStart
  &#39;some code
end sub
sub Application_OnEnd
  &#39;some code
end sub
sub Session_OnStart
  &#39;some code
end sub
sub Session_OnEnd
  &#39;some code
end sub
</script>
Copy after login

Note: Since ASP's script delimiters (<% and %>) cannot be used in Global.asa To insert a script into a file, we need to use the HTML

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!