SSI directives provide a way for users to insert the contents of one file into another file before the WEB server is processed. The ASP uses only #include directives for this mechanism. To insert a file in an. asp file, use the following syntax:
<!--#include Virtual | FILE = "FileName"-->
virtual and the file keyword indicate the type of path used to contain the file, filename is the path and name of the file that you want to include.
The included file does not require a special file name extension, but it is a good programming practice to assign the. inc extension to the included file to differentiate it from other types of files.
uses the Virtual keyword
uses the virtual keyword to indicate that the path starts with the virtual directory. For example, if a file named Footer.inc belongs to a virtual directory named/myapp, the following row inserts the contents of Footer.inc into the file containing the row:
<!--#include virtual "/myapp/footer.inc"-->
using the File keyword
uses the file keyword to indicate that a relative path is used. The relative path begins with the directory containing the containing file. For example, if your file is in the directory Myapp and the file Header1.inc is in Myappheaders, the following line inserts Header1.inc into your file:
Note that the path to the included file Headers/header1.inc is relative to the containing file, and if the script containing the #include statement is not in the/myapp directory, then the statement will not work.
if the enable upper-level directory option is selected in Internet Services Manager, you can also use the file keyword and ... /syntax contains the parent directory, which is the file in the previous level directory. For commands, see Configuring ASP applications.
the location of the included file
included files can be in a directory within your Web site, or outside your Web site. Typically, you should make the included files in the directory of your Web site. If a included file is located within your Web site, the next time the browser requests the include file, the changes to the included file are displayed. However, if the included file is outside your Web site, this change will not be reflected until the ASP application restarts or the Web server restarts. The ASP detects changes to any include files in the application's namespace (in the application's starting directory).
Include files: Hints and warnings
a contained file can also contain other files. If the #include instruction does not cause a loop, an. asp file can include the same file multiple times. For example, if the file first.asp contains a file second.inc, then second.inc must no longer contain first.asp. A file cannot contain itself. The ASP detects such loops or nesting errors, generates an error message when detected, and stops processing the requested. asp file.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.