ServerVariables Action on a path

Source: Internet
Author: User
Tags header http request iis variables servervariables unique id port number metabase
Some days ago sent a number of posts, to ask questions about the path, but also has not replied. In fact, my concept of the path has been relatively vague, and then also introduced the ServerVariables data collection, so that I solved the problem that puzzled me for a long time. Reprint this article, on the one hand see can help those and I have shared feelings of friends, but also hope that seniors can give more advice.


ServerVariables
The ServerVariables collection retrieves the predetermined environment variables.

Grammar
Request.ServerVariables (server environment variable)

Parameters
Server environment variables
Specifies the name of the server environment variable to retrieve. You can use the values listed below. Variable description
All_http all HTTP header files sent by the client.
All_raw retrieves all the headers in the unhandled table. Unlike All_raw and all_http, all_http places HTTP_ prefix in front of the title filename, and the title name is always capitalized. When you use All_raw, the title name and value appear only when the client sends it.
Appl_md_path retrieves the metabase path of the (WAM) application of the ISAPI DLL.
Appl_physical_path retrieves the physical path corresponding to the metabase path. IIS returns a value by converting Appl_md_path to a physical (directory) path.
Auth_password the value into the client's authentication dialog. This variable is available only if you are using Basic authentication.
Auth_type This is the authentication method that the server uses to verify the user's access to the protected script.
Auth_User the user name that was not authenticated.
Cert_cookie the unique ID of the client validation, returned as a string. A signature that can be validated as an entire client.
Cert_flags If there is client-side validation, then Bit0 is 1.
If the authentication of the client is invalid (not in the list of the CAs recognized by the server), Bit1 is set to 1.

Cert_issuer the Publisher field (O=ms,ou=ias,cn=user Name,c=usa) in user authentication.
Cert_keysize the number of digits of the Secure Sockets Layer connection key, such as 128.
Cert_secretkeysize server verifies the number of digits for private keywords. such as 1024.
Cert_serialnumber the user-validated serial number field.
Cert_server_issuer the Issuer field of the server authentication.
Cert_server_subject The primary field for server authentication.
Cert_subject The primary field for client authentication.
Content_length the length of the content that the client emits.
Content_Type the data type of the content. Used with queries with additional information, such as HTTP query get, POST, and put.
Revision of CGI specifications used by the Gateway_interface server. The format is cgi/revision.
http_Note The server interprets the underscore (_) in the Headername as a dash in the actual caption. For example, if you specify Http_my_header, the server searches for a header file that is sent in My-header name.

HTTPS returns on if the request crosses the secure channel (SSL). Returns off if the request is from a unsecured channel.
Https_keysize the number of digits of the Secure Sockets Layer connection key, such as 128.
Https_secretkeysize server verifies the number of digits for private keywords. such as 1024.
Https_server_issuer the Issuer field of the server authentication.
Https_server_subject The primary field for server authentication.
instance_id the ID of the IIS instance for text format. If the instance ID is 1, it appears as a character. Use this variable to retrieve the ID of the Web server instance (in the metabase) to which the request belongs.
Instance_meta_path the metabase path of the IIS instance that responds to the request.
LOCAL_ADDR returns the server address that accepts the request. This variable is important if the address used by the request is found on a multihomed machine that binds multiple IP addresses.
Logon_User User Login to the Windows NT® account.
Path_info the additional path information provided by the client. You can use these virtual paths and Path_info server variables to access scripts. If the information came from a URL, it was decoded by the server before it reached the CGI script.
Path_translated Path_info the converted version, which takes the path and makes the necessary virtual to physical mappings.
Query_string the information after the question mark (?) in the HTTP request is queried.
REMOTE_ADDR the IP address of the remote host that issued the request.
Remote_host the name of the host that issued the request. If the server does not have this information, it will be set to an empty mote_addr variable.
Remote_user user name string that is sent by the user. The name is the name that the user actually sends, relative to the name of the server after the validation filter has been modified.
Request_method This method is used to make a request. The equivalent of, POST, etc. for HTTP.
Script_name the virtual path to execute the script. The URL to use for the self reference.
server_name the server host name, DNS alias, or IP address that appears in the self-referencing UAL.
Server_port the port number where the request is sent.
Server_port_secure contains a string of 0 or 1. 1 if the security port handles the request, otherwise 0.
Server_protocol the name and revision of the request Information protocol. The format is protocol/revision.
Server_software the name and version of the server software that answers the request and runs the gateway. The format is name/version.
The URL provides the basic part of the URL.


Comments
If the client sends a header file that is not found in the table above, you can prefix the header file name with HTTP_ in the call Request.ServerVariables to retrieve its value. For example, if a client sends a header file

Somenewheader:somenewvalue

You can retrieve somenewvalue by using the following syntax

<% Request.ServerVariables ("Http_somenewheader")%>

You can iterate through all the server variable names by using the restatement character. For example, use the following script to print out all the server names.

<TABLE>
<tr><td><b>server variable</b></td><td><b>value</b></td> </TR>
<% for each name in Request.ServerVariables%>
<TR><TD> <%= name%> </TD><TD> <%= request.servervariables (name)%> </TD> </TR>
</TABLE>
<% Next%>

Example
The following example uses the Request object to display some server variables.

<HTML>
<!--This example displays the content of several servervariables. -->
All_http server variable =
<%= Request.ServerVariables ("All_http")%> <BR>
CONTENT_LENGTH server variable =
<%= Request.ServerVariables ("Content_length")%> <BR>
Content_Type server variable =
<%= Request.ServerVariables ("Content_Type")%> <BR>
Query_string server variable =
<%= Request.ServerVariables ("query_string")%> <BR>
Server_software server variable =
<%= Request.ServerVariables ("Server_software")%> <BR>
</HTML>

The next example uses the ServerVariables collection to insert the server name into a hypertext link.

<a HREF = "http://<%= request.servervariables (" SERVER_NAME ")%>
/scripts/mypage.asp ">link to Mypage.asp</a>


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.