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.
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 file.
The Global.asa file can contain only the following:
- Application events
- Session events
- <object> declarations
- TypeLibrary declarations
- the #include directive
Application and Session Events
In Global.asa you can tell the application and session objects what to do when the application/session starts and what to do when the application/session ends. The code for this is placed in event handlers. Note: We do not use <% and %>, to insert scripts in the Global.asa file, we have to put the subroutines inside the HTML <script> tag:
<script language="vbscript" runat="server">
sub Application_OnStart
' some code
end sub
sub Application_OnEnd
' some code
end sub
sub Session_OnStart
' some code
end sub
sub Session_OnEnd
' some code
end sub
</script>
<object> Declarations
Syntax:
{progid="progID"|classid="classID"}>
.......
</object>
TypeLibrary Declarations
A TypeLibrary is a container for the contents of a DLL file corresponding to a COM object. By including a call to the TypeLibrary in the Global.asa file, the constants of the COM object can be accessed, and errors can be better reported by the ASP code. If your Web application relies on COM objects that have declared data types in type libraries, you can declare the type libraries in Global.asa.
Syntax:
file="filename"
uuid="typelibraryuuid"
version="versionnumber"
lcid="localeid"
-->
Practice Excercise Practice now