ASP ServerVariables 集合

Request Object Reference Manual

定义和用法

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

语法

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

服务器变量

变量 描述
ALL_HTTP 返回客户端发送的所有HTTP标题。始终以HTTP_为前缀并大写
ALL_RAW 以原始形式返回所有标题
APPL_MD_PATH 返回用于ISAPI DLL的应用程序的元基本路径
APPL_PHYSICAL_PATH 返回对应于元基本路径的物理路径
AUTH_PASSWORD 返回客户端认证对话框中输入的值
AUTH_TYPE 服务器用于验证用户的认证方法
AUTH_USER 返回原始认证用户名
CERT_COOKIE Returns the unique ID for client certificate as a string
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the certification authority of the client certificate is not valid
CERT_ISSUER Returns the issuer field of the client certificate
CERT_KEYSIZE 返回安全套接字层连接密钥大小的位数
CERT_SECRETKEYSIZE 返回服务器证书私钥中的位数
CERT_SERIALNUMBER Returns the serial number field of the client certificate
CERT_SERVER_ISSUER 返回服务器证书的发行者字段
CERT_SERVER_SUBJECT 返回服务器证书的主题字段
CERT_SUBJECT Returns the subject field of the client certificate
CONTENT_LENGTH Returns the length of the content as sent by the client
CONTENT_TYPE Returns the data type of the content
GATEWAY_INTERFACE Returns the revision of the CGI specification used by the server
HTTP_<HeaderName> Returns the value stored in the header HeaderName
HTTP_ACCEPT Returns the value of the Accept header
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content
HTTP_COOKIE Returns the cookie string included with the request
HTTP_REFERER 返回包含将请求重定向到当前页面的页面的URL的字符串。如果页面已重定向,则HTTP_REFERER为空
HTTP_USER_AGENT 返回描述发送请求的浏览器的字符串
HTTPS 如果请求通过安全通道进入,则返回ON,如果请求通过非安全通道进入,则返回OFF
HTTPS_KEYSIZE 返回安全套接字层连接密钥大小的位数
HTTPS_SECRETKEYSIZE 返回服务器证书私钥中的位数
HTTPS_SERVER_ISSUER 返回服务器证书的发行者字段
HTTPS_SERVER_SUBJECT 返回服务器证书的主题字段
INSTANCE_ID 以文本格式表示的IIS实例ID
INSTANCE_META_PATH 响应请求的IIS实例的元基本路径
LOCAL_ADDR 返回请求进入的服务器地址
LOGON_USER 返回用户登录的Windows账户
PATH_INFO 返回客户端提供的额外路径信息
PATH_TRANSLATED PATH_INFO的翻译版本,它接受路径并执行任何必要的虚拟到物理映射
QUERY_STRING 返回存储在HTTP请求中问号(?)之后字符串中的查询信息
REMOTE_ADDR 返回发起请求的远程主机的IP地址
REMOTE_HOST 返回发起请求的主机名
REMOTE_USER 返回用户发送的未映射的用户名字符串
REQUEST_METHOD 返回用于发出请求的方法
SCRIPT_NAME 返回正在执行的脚本的虚拟路径
SERVER_NAME 返回服务器的主机名、DNS别名或IP地址,正如它将出现在自引用URL中一样
SERVER_PORT 返回请求发送到的端口号
SERVER_PORT_SECURE 返回包含0或1的字符串。如果请求正在安全端口上处理,则它将是1。否则,它将是0
SERVER_PROTOCOL Returns the name and revision of the request information protocol
SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway
URL Returns the base portion of the URL

Instance

Example 1

You can iterate through all the server variables like this:

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

Example 2

This example demonstrates how to find out the visitor's browser type, IP address, and so on:

<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 Object Reference Manual