Server-side Include directives

Source: Internet
Author: User
What can be done with server-side include (SSI) statements (or directives)? Not much, unless you intend to create an executable file that runs on a Web server and access the ISAPI through STDIN and STDOUT functions. This means that you can use C, C + + or other languages (such as Delphi) to write them, but VB is not suitable. What's more, what you can do with SSI directives can do just as well in the ASP. In many ways, the SSI features of IIS are backward compatible with the original web site and Web pages that use these features.
However, you may sometimes want to use SSI instead of ASP on your site. In IIS 5.0, server-side include directives can be more easily integrated into ASP pages at a remote site than before, and they are useful, especially as a way to execute operating system commands or legacy CGI applications. The instructions that are available will be described in great detail later.
#include指令是这些指令之一, it has been in use with ASP for some time and also in SSI pages. In fact, this has caused a lot of confusion for ASP developers who don't have traditional web development backgrounds.
4.2.1 an incredible ASP #include指令
In an ASP page, you can use the #include directive to insert the contents of another file into the current page:
<!--#include file= "/scripts/usefulbits.inc"-->
This instruction reads the entire contents of the file and inserts it into the page, replacing the <!--#include ... --> line. This is a very useful technique for inserting HTML paragraphs that can be reused. You also use this directive to insert code snippets. For example, if you have a file that contains several scripting functions (or just a single line of scripting code) that are used in several pages at the same time, you can use the #include directive to insert it into each page that requires it.
By separating the scripts from the content, you provide a level of composition for the page. This means that if the script is modified, the script's modifications are automatically reflected in each page that uses the containing file when the client opens the page again. Including files is also a simple way to insert server-specific information, so moving the site to another server does not mean you must edit all pages that involve the original server (the obvious example is a database connection string or a link that specifies a complete URL or server name). This can greatly reduce maintenance costs.
For example, you can name the following as a containing file named Connect.inc:
<%
strconnect = "Server=myserver;database=mydb;driver={sql SERVER};" _
& "Uid=username; Pwd=secretpassword "
%>
You can then use this file on any page:
<!--#include file= "Path_to_fileconnect.inc"-->
<%
...
strtheconnectionstring = StrConnect ' from include file

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.