[This is preliminary documentation and subject to change]

Using Server-Side Include Directives

You use server-side include (SSI) directives to instruct the Web server to add text, graphic, or application content to a Web page just before sending the page to the client's browser. SSI provides special preprocessing directives that help you access information about a file or display the value of a CGI variable. SSI also provides a directive that you can use to insert the output from an application or a shell command into a Web page.

important Important    The #include statement is processed at compile time, not at run time. Therefore, you cannot incorporate this statement into the logic of your client-side procedures.

Including Files

To include a file, use the #include directive. For example, to insert a file named Copyright.inc into a Web page when it is requested, use the following directive in the Web page:

<!-- #include file="Copyright.inc" -->

In this example, the file Copyright.inc must be in the same directory as the include file. The file that contains the #include directive must be a published file in your Web site. Included files do not require a special file name extension; however, it is considered good programming practice to give included files an .inc extension to distinguish them from other types of files.

To locate the include file by specifying a path relative to the current directory, use the file argument. For example, if the calling file is in a directory named Documents and the include file is in a subdirectory named Documents\Common, use the following directive:

<!-- #include file="Common\Copyright.inc" -->

While you are working with documents in a Web site, you may want to store shared files in a special virtual directory. To locate the include file by specifying the full virtual path to the file, use the virtual argument. For example, to include a file from the /Common virtual directory, use the following directive:

<!-- #include virtual="/Common/Copyright.inc" -->

Including Output from Applications

In addition to including the contents of a file, you can run an application or a shell command by using an SSI directive and include the output on your Web page. To run an application or a shell command, use the #exec directive. The application can be a CGI program, an ASP application, or an ISAPI extension. For example:

<!-- #exec cgi=/scripts/guestbook.exe?FirstName+LastName>

The path to the application must be a full virtual path, or URL. You can pass parameters to the application by following the application's file name with a question mark (?) and a list of parameters joined by plus signs (+).

important Important    Allowing ordinary Web files to run applications presents a security risk. You can disable the #exec directive and still allow Web pages to use the other SSI directives.

For more information, see the Server-Side Includes Reference.


© 1997-2001 Microsoft Corporation. All rights reserved.