[This is preliminary documentation and subject to change]

#include

The #include 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 Internet Service Manager installed, you can modify default extension mappings and add new mappings; see Setting Application 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 with 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 TypeMeaning
FileThe 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 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.
VirtualThe file name is a full virtual path from a virtual directory in 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 (").

Remarks

The file containing this directive must use 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).

An STM page using the #echo directive must be run by itself, or by calling it from an ASP page with Response.Redirect. Calling an STM page from an ASP page with Server.Transfer, Server.Execute, or #include will not work because that would force the STM page to go through asp.dll instead of through ssinc.dll.

If you have the IIS snap-in installed, you can modify default extension mappings and add new mappings; see Setting Application Mappings. Since you cannot map a file extension to more than one executable, you cannot use this directive in ASP files. ASP files are already mapped to the asp.dll and must stay that way.

Example

--- 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" -->


© 1997-2001 Microsoft Corporation. All rights reserved.