Obtain the IP address of the client. The Code is as follows:
Copy codeThe Code is as follows: // <summary>
/// Obtain the Client IP Address
/// </Summary>
/// <Returns> </returns>
Public string GetClientIP ()
{
String userIP = Request. ServerVariables ["HTTP_X_FORWARDED_FOR"];
If (userIP = null)
UserIP = Request. ServerVariables ["REMOTE_ADDR"];
Return userIP;
}
Glossary: ServerVariables -- server Variables
Request. ServerVariables ("Url ")
Back to server address
Request. ServerVariables ("Path_Info ")
Path information provided by the client
Request. ServerVariables ("Appl_Physical_Path ")
Physical path corresponding to the application metadatabase path
Request. ServerVariables ("Path_Translated ")
Path obtained after ing from virtual to physical
Request. ServerVariables ("Script_Name ")
Script Execution name
Request. ServerVariables ("Query_String ")
Query string content
Request. ServerVariables ("Http_Referer ")
Request string content
Request. ServerVariables ("Server_Port ")
Server port number that receives the request
Request. ServerVariables ("Remote_Addr ")
IP address of the remote host that sends the request
Request. ServerVariables ("Remote_Host ")
Name of the remote host that sends the request
Request. ServerVariables ("Local_Addr ")
Returns the server address that receives the request.
Request. ServerVariables ("Http_Host ")
Back to server address
Request. ServerVariables ("Server_Name ")
Host Name, DNS address, or IP address of the server
Request. ServerVariables ("Request_Method ")
Request methods such as GET, HEAD, and POST
Request. ServerVariables ("Server_Port_Secure ")
If the server port receiving the request is a security port, the value is 1. Otherwise, the value is 0.
Request. ServerVariables ("Server_Protocol ")
Name and version of the protocol used by the server
Request. ServerVariables ("Server_Software ")
Name and version of the server software that responds to the request and runs the Gateway
Request. ServerVariables ("All_Http ")
All HTTP headers sent by the client, prefixed with HTTP _
Request. ServerVariables ("All_Raw ")
All HTTP headers sent by the client have the same results as those sent by the client without the prefix HTTP _
Request. ServerVariables ("Appl_MD_Path ")
Metadatabase path of the application
Request. ServerVariables ("Content_Length ")
Length of the content sent by the client
Request. ServerVariables ("Https ")
If the request passes through the Secure Channel (SSL), ON is returned. If the request comes from an insecure channel, OFF is returned.
Request. ServerVariables ("Instance_ID ")
ID of the IIS instance
Request. ServerVariables ("Instance_Meta_Path ")
Metadatabase path of the IIS instance that responds to the request
Request. ServerVariables ("Http_Accept_Encoding ")
Returned content, such as gzip and deflate
Request. ServerVariables ("Http_Accept_Language ")
Returned content, for example, en-us
Request. ServerVariables ("Http_Connection ")
Returned content: Keep-Alive
Request. ServerVariables ("Http_Cookie ")
Returned content, for example, nVisiT %
2 DYum = 125; ASPSESSIONIDCARTQTRA = FDOBFFABJGOECBBKHKGPFIJI; aspsessionidcaqqtsulfate = lkjjplabillpcogjgamkam; ASPSESSIONIDACRRSSRA = DK
HHHFBBJOJCCONPPHLKGHPB
Request. ServerVariables ("Http_User_Agent ")
Returned content: Mozilla/4.0 (compatible; MSIE6.0; WindowsNT5.1; SV1)
Request. ServerVariables ("Https_Keysize ")
Number of connections in the Secure Socket Layer, such as 128
Request. ServerVariables ("Https_Secretkeysize ")
The number of bits for Server Authentication for private keywords, for example, 1024
Request. ServerVariables ("Https_Server_Issuer ")
Issuer field of the server certificate
Request. ServerVariables ("Https_Server_Subject ")
Topic field of the server certificate
Request. ServerVariables ("Auth_Password ")
The password entered in the Password dialog box when the Basic Authentication mode is used
Request. ServerVariables ("Auth_Type ")
When a user accesses a protected script, the server is used to verify the user's authentication method.
Request. ServerVariables ("Auth_User ")
User Name of the Credential
Request. ServerVariables ("Cert_Cookie ")
Unique customer certificate ID
Request. ServerVariables ("Cert_Flag ")
The customer certificate is marked as a token. If a client certificate exists, bit0 is 0. If the client certificate verification is invalid, bit1 is set to 1.
Request. ServerVariables ("Cert_Issuer ")
Issuer field in the user certificate
Request. ServerVariables ("Cert_Keysize ")
Number of connections in the Secure Socket Layer, such as 128
Request. ServerVariables ("Cert_Secretkeysize ")
The number of bits for Server Authentication for private keywords, for example, 1024
Request. ServerVariables ("Cert_Serialnumber ")
Serial number field of the customer Certificate
Request. ServerVariables ("Cert_Server_Issuer ")
Issuer field of the server certificate
Request. ServerVariables ("Cert_Server_Subject ")
Topic field of the server certificate
Request. ServerVariables ("Cert_Subject ")
Subject field of the client certificate
Request. ServerVariables ("Content_Type ")
Form Content or HTTPPUT data type sent by the customer
Request. ServerVariables ("HTTP_X_FORWARDED_FOR ")
You can obtain the direct IP address after the proxy (GATEWAY). Of course, this proxy must be supported.
Some Hidden Request. ServerVariables parameters:
Request. ServerVariables ("NUMBER_OF_PROCESSORS ")
Request. ServerVariables ("OS ")
Request. ServerVariables ("WINDIR ")
Request. ServerVariables ("TEMP ")
Request. ServerVariables ("TMP ")
Request. ServerVariables ("ComSpec ")
Request. ServerVariables ("Os2LibPath ")
Request. ServerVariables ("Path ")
Request. ServerVariables ("PATHEXT ")
Request. ServerVariables ("PROCESSOR_ARCHITECTURE ")
Request. ServerVariables ("PROCESSOR_IDENTIFIER ")
Request. ServerVariables ("PROCESSOR_LEVEL ")
Request. ServerVariables ("PROCESSOR_REVISION ")
Local ip address: <% = request. servervariables ("remote_addr") %>
Server Name: <% = Request. ServerVariables ("SERVER_NAME") %>
Server IP: <% = Request. ServerVariables ("LOCAL_ADDR") %>
Server port: <% = Request. ServerVariables ("SERVER_PORT") %>
Server time: <% = now %>
IIS Version: <% = Request. ServerVariables ("SERVER_SOFTWARE") %>
Script Timeout: <% = Server. ScriptTimeout %>
Path of this file: <% = server. mappath (Request. ServerVariables ("SCRIPT_NAME") %>
Server CPU usage: <% = Request. ServerVariables ("NUMBER_OF_PROCESSORS") %>
Server interpretation engine: <% = ScriptEngine & "/" & ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion & "." & ScriptEngineBuildVersion %>
Server Operating System: <% = Request. ServerVariables ("OS") %>
Supported file types: <% = Request. ServerVariables ("HTTP_Accept") %>
Path of the accessed file: <% = Request. ServerVariables ("HTTP_url") %>
User Agent Information: <% = Request. ServerVariables ("HTTP_USER_AGENT") %>