ASP ServerVariables 集合

Request 对象参考手册

定义和用法

ServerVariables 集合用于取回服务器变量的值。

语法

Request.ServerVariables (server_variable)
参数描述
server_variable必需。要取回的服务器变量的名称。

服务器变量

变量描述
ALL_HTTPReturns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAWReturns all headers in raw form
APPL_MD_PATHReturns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATHReturns the physical path corresponding to the meta base path
AUTH_PASSWORDReturns the value entered in the client's authentication dialog
AUTH_TYPEThe authentication method that the server uses to validate users
AUTH_USERReturns the raw authenticated user name
CERT_COOKIEReturns the unique ID for client certificate as a string
CERT_FLAGSbit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUERReturns the issuer field of the client certificate
CERT_KEYSIZEReturns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZEReturns the number of bits in server certificate private key
CERT_SERIALNUMBERReturns the serial number field of the client certificate
CERT_SERVER_ISSUERReturns the issuer field of the server certificate
CERT_SERVER_SUBJECTReturns the subject field of the server certificate
CERT_SUBJECTReturns the subject field of the client certificate
CONTENT_LENGTHReturns the length of the content as sent by the client
CONTENT_TYPEReturns the data type of the content
GATEWAY_INTERFACEReturns the revision of the CGI specification used by the server
HTTP_<HeaderName>Returns the value stored in the header HeaderName
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 included with the request
HTTP_REFERERReturns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENTReturns a string describing the browser that sent the request
HTTPSReturns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZEReturns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZEReturns the number of bits in server certificate private key
HTTPS_SERVER_ISSUERReturns the issuer field of the server certificate
HTTPS_SERVER_SUBJECTReturns the subject field of the server certificate
INSTANCE_IDThe ID for the IIS instance in text format
INSTANCE_META_PATHThe meta base path for the instance of IIS that responds to the request
LOCAL_ADDRReturns the server address on which the request came in
LOGON_USERReturns the Windows account that the user is logged into
PATH_INFOReturns extra path information as given by the client
PATH_TRANSLATEDA translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRINGReturns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDRReturns the IP address of the remote host making the request
REMOTE_HOSTReturns the name of the host making the request
REMOTE_USERReturns an unmapped user-name string sent in by the user
REQUEST_METHODReturns the method used to make the request
SCRIPT_NAMEReturns a virtual path to the script being executed
SERVER_NAMEReturns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORTReturns the port number to which the request was sent
SERVER_PORT_SECUREReturns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOLReturns the name and revision of the request information protocol
SERVER_SOFTWAREReturns the name and version of the server software that answers the request and runs the gateway
URLReturns the base portion of the URL

实例

例子 1

您可以像这样来循环遍历所有的服务器变量:

<%
for each x in Request.ServerVariables
response.write(x & "<br />")
next
%>

例子 2

本例演示了如何查明访问者浏览器的类型、IP 地址等等:

<html>
<body>
<p>
<b>You are browsing this site with:</b>
<%Response.Write(Request.ServerVariables("http_user_agent"))%>
</p>
<p>
<b>Your IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_addr"))%>
</p>
<p>
<b>The DNS lookup of the IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_host"))%>
</p>
<p>
<b>The method used to call the page:</b>
<%Response.Write(Request.ServerVariables("request_method"))%>
</p>
<p>
<b>The server's domain name:</b>
<%Response.Write(Request.ServerVariables("server_name"))%>
</p>
<p>
<b>The server's port:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>
</body>
</html>

Request 对象参考手册