ASP 3.0 Advanced Programming (12)

Source: Internet
Author: User
Tags date format anonymous object file size include insert access
Programming | Advanced 4.2.3 Examples of server-side include directives
This section provides sample pages that you can use to experiment with a variety of server-side include statements. Opens the subdirectory Chapter04 for the sample Web page, displaying the SSI directives and the ASP Server Object home page (that is, default.asp in the subdirectory Chapter04), as shown in Figure 4-3:

Figure 4-3 Example Web page
All of the examples in this book can be downloaded from our web site. Readers will find all the sample pages in the remainder of this chapter in the subdirectory Chapter04 of the sample.
1. Using ssi/cgi processing instructions
Click the link to enter the Server-side Include and CGI statements page, which opens the Ssi_cgi.stm page. Note that the file name extension for this page is. stm, which indicates that this is not an ASP Web page. The page uses all of the SSI directives that were previously discussed except for the #exec directive (see later), and shows how and how the instructions are used, as shown in Figure 4-4:

Figure 4-4 the ssi/cgi processing instructions shown on the sample Web page
(1) #include指令
The beginning of the page, "Include Files with SSI", displays the contents of another separate file named Intro.inc. The following is the entire contents of the file:
Note that we must use the HTML entry "<" and ">" to display the angle brackets in the Web page. If this is not done, they cannot be treated as part of the annotation element and cause the instructions in them to be executed.
In the main ssi_cgi.stm page, the code to insert this file into the page is simple:
<!--#include file= "Intro.inc"-->
(2) #config, #fsize和 #flastmod instructions
The next section of the page shows the size of the file default.asp and the last modified time in the same directory as the page. #config instructions are used three times here:
· One time is to set the SSI error message.
· One time is to format the date and time.
· The format of the file size calculation is set once.
Insert values into the Web page using the #fsize and #fiastmod directives:
<p><div class= "subhead" >ssi statements</div>
<!--#config errmsg= "SSI processing Error"-->
(sets error message in case of SSI error) <BR>
<!--#config errmsg= "SSI processing Error"--><p>

Details of file ' Default.asp ':<br>
<!--#config sizefmt= "BYTES"-->
(Sets Fsize to return size in bytes) <BR>
<!--#config sizefmt= "BYTES"-->

<!--#fsize file= "Default.asp"-->
Returns: <B><!--#fsize file= "Default.asp"--> bytes</b><br>

<!--#config timefmt= "%A,%B%d%Y%h:%m:%s"-->
(sets format for date/time results) <BR>
<!--#config timefmt= "%A,%B%d%Y%h:%m:%s"-->

<!--#flastmod file= "Default.asp"-->
Returns: <B><!--#flastmod file= "Default.asp"--></b><p>
(3) #echo instruction
The last part of the page (see only a portion of the screen) shows the contents of all HTTP headers that can be accessed using the #echo directive. The code for each line is the same, only the value of the var attribute changes. A complete list of all allowable values for the Var attribute is given in Appendix G.
<div class= "subhead" >http variables</div>
<!--#echo var= "Auth_type"-->
Returns: <B><!--#echo var= "Auth_type"--></b><br>
<!--#echo var= "Auth_password"-->
Returns: <B><!--#echo var= "Auth_password"--></b><br>
... etc...
2. Using the #exec directive
#exec指令与其他的SSI指令相比使用起来困难一些, because of this, put it on the other page independently. You can access the startup page from the ASP Server Object and SSI Directives main menu.
On this page, select the Using the #echo server-side Include Directive link. This operation opens the "SSI #exec Directive" page, as shown in Figure 4-5:

Figure 4-5 "The SSI #exec Directive" page
This is an ASP page ssi_exec.asp. Two buttons to open the. stm page, which performs the action described in the #exec instruction.
(1) Run this example on the server
In SSI #exec指令示例能够在服务器上工作之前, some configuration modifications must be made. First, you need to create the SSIEnableCmdDirective entry (type DWORD) in the registry of the Web server, in the following key name:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters
The value is then set to 1, as shown in Figure 4-6:

Figure 4-6 setting in the registry
This allows the #exec instruction to be used in conjunction with the Cmd property.
Second, anonymous access must be disabled for the directory containing the. stm file with the #exec directive, and the client will be forced to provide details of the account, which should be an account with Administrator level permissions. This is also the requirement that net commands work correctly.
Activate the Internet Services Manager application and select the directory containing the. stm files that use the #exec directive (in the example, these files are start_cisvc.stm and stop_cisvc.stm in the EXEC directory). Then open the Properties dialog box for the directory. In the Directory Security tab, click the Edit button in the anonymous access and authentication control area to open the Authentication Methods dialog box, as shown in Figure 4-7:

Figure 4-7 dialog box to set the validation method
This dialog box does not select the Anonymous access check box. If you do not use Internet Explorer to access this page, open the Basic authentication option to allow non-ie browsers to access the page by submitting a username/password. When setting, a security warning appears, and click Yes. The browser will now be forced to produce the appropriate account number and identity certificate, because the Web page cannot be accessed anonymously.
To see the results of the start and end service, open the Services MMC plug-in to terminate the Indexing Service, as shown in Figure 4-8:

Figure 4-8 Screen for starting and terminating services
(2) Start and terminate indexing Service
Click the button on the sample Web page to start the Microsoft Indexing Service.
The short name for this service is cisvc, which is commonly referred to as the Microsoft Index Se

[1] [2] Next page



Related Article

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.