How to include an external file in global.asa

Language: Classic ASP

Challenge:

How to include an external file in global.asa

global.asa is an optional file used by just about every Classic ASP site of any complexity. It can contain declarations of objects, variables, and functions used throughout the site.

Benefits to global.asa include:

  • Declarations made in global.asa are available in ASP page of the site.
  • A variety of scripts (JavaScript, VBScript, JScript, PerlScript, any other client side script) can be used within.

The global.asa file is stored in the root directory and loaded by IIS automatically each time a page is called.

SOLUTION:

Language: Classic ASP

Challenge:

How to include an external file in global.asa

global.asa is an optional file used by just about every Classic ASP site of any complexity. It can contain declarations of objects, variables, and functions used throughout the site.

Benefits to global.asa include:

  • Declarations made in global.asa are available in ASP page of the site.
  • A variety of scripts (JavaScript, VBScript, JScript, PerlScript, any other client side script) can be used within.

The global.asa file is stored in the root directory and loaded by IIS automatically each time a page is called.

Solution:

To include an external file in global.asa simply add this code and change “./myFileName.asp” to reference the desired file and location.

<!– #include file=”./myFileName.asp” –>

Including external files can be handy if you want to save yourself from repeating code unnecessarily. For example I might include my dbConnect file to help guarantee my connection string is defined and ready for use throughout the site.