Use the Request object to obtain the environment parameters of the machine

Source: Internet
Author: User
Tags http request servervariables variable client port number
request| objects
The Reques object is able to save all the information sent from the browser's client to the server, which is part of the client's environmental information, which can be read by the Reques object, thereby enabling the client's environment to be known.

   what are the common parameters for the ServerVariables collection?
To use the Reques object to read the environment parameters of the client, the ServerVariables collection object is used to save the environment variable.
The following charts are some of the more commonly used parameters of the ServerVariables collection:
All_http: All HTTP header files sent by the client.
Content_length: The length of the content that the client emits.
Content_Type: The data type of the content. such as: "text/html". Used with queries with additional information, such as HTTP query get, POST, and put.
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 Windows NT account
Query_string: Queries the message after the question mark (?) in the HTTP request.
REMOTE_ADDR: The IP address of the remote host (client) that issued the request.
Remote_host: the host (client) name that issued the request. If the server does not have this information, it will be set to an empty mote_addr variable.
Request_method: This method is used to make a request. The equivalent of, post, etc. for HTTP.
SERVER_NAME: The server host name, DNS alias, or IP address that appears in the self-referencing URL.
Server_port: The port number on which the request is sent.
Http_accept_language: The language environment used by machines
ServerVariables: What is the syntax of a collection object?
The specific syntax of this collection object in the program is as follows: Request.ServerVariables (server environment variable)

   How do I get the environment parameters of the machine through the request object?
Example name request.asp, his main role is to read the local IP address, server-side IP address and machine use of the language environment, the source program is as follows:
<HTML>
<HEAD>
<TITLE> get the environment parameters for the client </TITLE>
</HEAD>
<BODY>
<%dim Language ' language for storing client-side environments Response.Write "Local IP Address:" & Request.ServerVariables ("Local_addr") Response.Write "
<HR>
"Response.Write" Server IP Address: "& Request.ServerVariables" REMOTE_ADDR ") Language = Request.ServerVariables (" Http_ Accept_language ") Response.Write"
<HR>
"Select Case Language" ZH-TW ": Response.Write" You are using traditional Chinese "case" ZH-CN ": Response.Write" You are using the Simplified Chinese "end select%>
<HR>
</BODY>
</HTML>
After execution, you can get the following interface:

Use the Request object to read environment parameters
There are other parameters defined in the ServerVariables set, and the best way to use them flexibly is to use them more.



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.