#echo

The #echo Server-Side Include (SSI) directive instructs the Web server to display the value of a server variable. You must surround a directive with HTML comment delimiters.

By default, this directive can be used only in STM pages; it cannot be used in ASP pages. For ASP pages, you can access some of the variables listed below by using the Request.ServerVariables Collection collection. For DATE_GMT and DATE_LOCAL, you can use VBScript and JScript functions in ASP pages.

句法

<!-- #echo var =VariableName-->

参数

VariableName
Specifies the name of the variable whose value you want to insert. The variable can be one of the following:

变量描述
ALL_HTTPAll HTTP headers sent by the client.
ALL_RAWRetrieves all headers in raw form. The difference between ALL_RAW and ALL_HTTP is that ALL_HTTP places an HTTP_ prefix before the header name and the header name is always capitalized. In ALL_RAW the header name and values appear as they are sent by the client.
APPL_MD_PATHRetrieves the metabase path for the Application for the ISAPI DLL.
APPL_PHYSICAL_PATHRetrieves the physical path corresponding to the metabase path. IIS converts the APPL_MD_PATH to the physical (directory) path to return this value.
AUTH_PASSWORDThe value entered in the client's authentication dialog. This variable is available only if Basic authentication is used.
AUTH_TYPEThe authentication method that the server uses to validate users when they attempt to access a protected script.
AUTH_USERThe name of the user as it is derived from the authorization header sent by the client, before the user name is mapped to a Windows account. This variable is no different from REMOTE_USER. If you have an authentication filter installed on your Web server that maps incoming users to accounts, use LOGON_USER to view the mapped user name.
CERT_COOKIEUnique ID for the client certificate, returned as a string. This can be used as a signature for the whole client certificate.
CERT_FLAGSbit0 is set to 1 if the client certificate is present.

bit1 is set to 1 if the certification authority of the client certificate is invalid (that is, it is not in the list of recognized certification authorities on the server).

CERT_ISSUERIssuer field of the client certificate (O=MS, OU=IAS, CN=user name, C=USA).
CERT_KEYSIZENumber of bits in the Secure Sockets Layer (SSL) connection key size. For example, 128.
CERT_SECRETKEYSIZENumber of bits in server certificate private key. For example, 1024.
CERT_SERIALNUMBERSerial number field of the client certificate.
CERT_SERVER_ISSUERIssuer field of the server certificate.
CERT_SERVER_SUBJECTSubject field of the server certificate.
CERT_SUBJECTSubject field of the client certificate.
CONTENT_LENGTHThe length of the content as given by the client.
CONTENT_TYPEThe data type of the content. Used with queries that have attached information, such as the HTTP queries GETPOST, and PUT.
GATEWAY_INTERFACEThe revision of the CGI specification used by the server. The format is CGI/revision.
HTTP_<HeaderName>The value stored in the header HeaderName. Any header other than those listed in this table must be preceded by "HTTP_" in order for the ServerVariables collection to retrieve its value.

Note:The server interprets any underscore (_) characters in HeaderName as dashes in the actual header. For example, if you specify HTTP_MY_HEADER, the server searches for a header sent as MY-HEADER.
HTTP_ACCEPTReturns the value of the Accept header.
HTTP_ACCEPT_LANGUAGEReturns a string describing the language to use for displaying content.
HTTP_COOKIEReturns the cookie string that was included with the request.
HTTP_HOSTReturns the name of the Web server. This may or may not be the same as SERVER_NAME, depending on type of name resolution you are using on your Web server (IP address or host header).
HTTP_REFERERReturns a string that contains the URL of the page that referred the request to the current page by using an HTML <A> tag. Note that the URL is the one that the user typed into the browser address bar, which may not include the name of a default document.

If the page is redirected, HTTP_REFERER is empty. HTTP_REFERER is not a mandatory member of the HTTP specification.

HTTP_USER_AGENTReturns a string describing the browser that sent the request.
HTTPSReturns ON if the request came in through a secure channel (for example, SSL); or it returns OFF, if the request is for an insecure channel.
HTTPS_KEYSIZENumber of bits in the SSL connection key size. For example, 128.
HTTPS_SECRETKEYSIZENumber of bits in the server certificate private key. For example, 1024.
HTTPS_SERVER_ISSUERIssuer field of the server certificate.
HTTPS_SERVER_SUBJECTSubject field of the server certificate.
INSTANCE_IDThe ID for the IIS instance in textual format. If the instance ID is 1, it appears as a string. You can use this variable to retrieve the ID of the Web server instance (in the metabase) to which the request belongs.
INSTANCE_META_PATHThe metabase path for the instance of IIS that responds to the request.
LOCAL_ADDRReturns the server address on which the request came in. This is important on computers where there can be multiple IP addresses bound to the computer, and you want to find out which address the request used.
LOGON_USERThe Windows account that the user is impersonating while connected to your Web server. Use REMOTE_USER,UNMAPPED_REMOTE_USER, or AUTH_USER to view the raw user name that is contained in the request header. The only time LOGON_USER holds a different value than these other variables is if you have an authentication filter installed.
PATH_INFOExtra path information, as given by the client. You can access scripts by using their virtual path and the PATH_INFOserver variable. If this information comes from a URL, it is decoded by the server before it is passed to the CGI script.
PATH_TRANSLATEDA translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping.
QUERY_STRINGQuery information stored in the string following the question mark (?) in the HTTP request.
REMOTE_ADDRThe IP address of the remote host that is making the request.
REMOTE_HOSTThe name of the host that is making the request. If the server does not have this information, it will set REMOTE_ADDRand leave this empty.
REMOTE_PORTThe client port number of the TCP connection.
REMOTE_USERThe name of the user as it is derived from the authorization header sent by the client, before the user name is mapped to a Windows account. If you have an authentication filter installed on your Web server that maps incoming users to accounts, use LOGON_USER to view the mapped user name.
REQUEST_METHODThe method used to make the request. For HTTP, this can be GETHEADPOST, and so on.
SCRIPT_NAMEA virtual path to the script being executed. This is used for self-referencing URLs.
SERVER_NAMEThe server's host name, DNS alias, or IP address as it would appear in self-referencing URLs.
SERVER_PORTThe server port number to which the request was sent.
SERVER_PORT_SECUREA string that contains either 0 or 1. If the request is being handled on the secure port, then this is 1. Otherwise, it is 0.
SERVER_PROTOCOLThe name and revision of the request information protocol. The format is protocol/revision.
SERVER_SOFTWAREThe name and version of the server software that answers the request and runs the gateway. The format isname/version.
UNMAPPED_REMOTE_USERThe name of the user as it is derived from the authorization header sent by the client, before the user name is mapped to a Windows account. This variable is no different from REMOTE_USER. If you have an authentication filter installed on your Web server that maps incoming users to accounts, use LOGON_USER to view the mapped user name.
URLGives the base portion of the URL.

备注

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 this directive must be run by itself or by calling it from an ASP page by using Response.Redirect. Calling an STM page from an ASP page with Server.TransferServer.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 Manager installed, you can modify default extension mappings and add new mappings; . Because you cannot map a file name extension to more than one executable, you cannot use thisdirective in ASP files. ASP files are already mapped to Asp.dll and must stay that way.

The following example uses the #echo directive to insert a URL into the ACTION value of a FORM statement.

--- Echo.asp ---

<FORM NAME="RunEcho" METHOD="POST" ACTION="Echo.asp"> 
<INPUT TYPE="SUBMIT" VALUE="Run the #echo Directive" NAME="RunEcho"> 
</FORM> 
<% 
If Len(Request.Form("RunEcho")) Then 
  Response.Redirect("Echo.stm?Echo.asp") 
End If 
%>

--- Echo.stm ---

<H3>Inside Echo.stm</H3> 
AUTH_TYPE is <!-- #echo var="AUTH_TYPE"--><BR> 
<FORM NAME="Return" METHOD="POST" ACTION="<!-- #echo var="QUERY_STRING"-->"> 
<INPUT TYPE="SUBMIT" VALUE="Return to Previous Page" NAME="Return"> 
</FORM>

必备条件

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

如果你喜欢这篇文章,敬请给站长打赏↑

除特别注明外,本站所有文章均为本站站长原译,转载请注明出处。