Share via


#include

The #include Server-Side Include (SSI) directive instructs the Web server to insert the contents of a file into a Web page. You must surround a directive with HTML comment delimiters.

This directive can be used in an ASP page, STM page, INC page, or any page with a file name extension that is mapped to the SSI interpreter (Ssinc.dll) or to the ASP interpreter (Asp.dll). If you have IIS Manager installed, you can modify default application mappings and add new mappings .

Included files can have any file name extension, but a recommended practice is to give them the .inc extension. Included files will go through the interpreter of the calling page. For example, if you want to include a page that uses the #exec directive, you must call it from an STM page. If you want to include a page that contains ASP script, you must call it from an ASP page. Included HTM pages will work as expected.

Syntax

<!-- #includePathType**=** FileName-->

Parameters
  • PathType
    Specifies the type of the path to FileName. The path type can be one of the following:

    Path Type Meaning
    File The FileName is a relative path from the directory containing the document with the #include directive. The included file can be in the same directory or in a subdirectory. The included file cannot be in a directory above the page with the #include directive unless you have checked the box for Enable Parent Paths in the property sheet for the web folder. This is strongly discouraged because it is a security risk. Any web user could type ../.. as a part of a URL for your site and be shown the contents of parent folders you may not want them to see.
    Virtual The file name is a full virtual path from a virtual directory of your Web site.
  • FileName
    Specifies the name of the file to be included. FileName must contain the file name extension, and you must enclose the file name in quotation marks (").

The file containing this directive must use an .asp file name extension, or a file name extension that is mapped to the SSI interpreter; otherwise, the Web server will not process the directive. By default, the file name extensions .stm, .shtm, and .shtml are mapped to the SSI interpreter (ssinc.dll).

The #include directive is the only directive that will work in .asp files as well as .stm, .shtm, and .shtml files.

--- IncExample.asp ---

  <!-- The included file is in the same directory as IncExample.asp. -->
<!-- #include file = "myfile.inc" -->

<!-- The included file is in the directory above IncExample.asp.
     Enable Parent Paths must be checked for the web folder. -->
<!-- #include file = "..\myfile.htm" -->

<!-- The included file is in the Scripts virtual directory. -->
<!-- #include virtual = "/scripts/tools/global.inc" -->