ASP. NET Get customer service IP, server IP

Source: Internet
Author: User
Tags servervariables server port metabase

Client IP:

Request.ServerVariables.Get ("REMOTE_ADDR"). ToString ();

Client Host Name:

Request.ServerVariables.Get ("Remote_host"). ToString ();

client browser ie:

Request.Browser.Browser;

client browser version number:

request.browser.majorversion;//

Client operating system:

Request.Browser.Platform;

Server IP:

Request.ServerVariables.Get ("Local_addr"). ToString ();

Server name:

Request.ServerVariables.Get ("SERVER_NAME"). ToString ();

If you want to learn more about ServerVariables, you can use

foreach (String o in Request.ServerVariables){
Response.Write (o+ "=" +request.servervariables[o]+ "<br>");

Get Client IP method

public string GetIP ()
{
String uip = "";
if (httpcontext.current.request.servervariables["Http_via"]! = NULL)
{
UIP = httpcontext.current.request.servervariables["Http_x_forwarded_for"]. ToString ();
}
Else
{
UIP = httpcontext.current.request.servervariables["REMOTE_ADDR"]. ToString ();
}
return UIP;
}C # ServerVariables parameter description

request.servervariables["URL"]
Return server address

request.servervariables["Path_info"]
Path information provided by the client

request.servervariables["Appl_physical_path"]
The physical path corresponding to the application metabase path

request.servervariables["Path_translated"]
Paths obtained from virtual to physical mapping

request.servervariables["Script_name"]
Name of the execution script

request.servervariables["Query_string"]
Query string content

request.servervariables["Http_referer"]
The requested string content

request.servervariables["Server_port"]
Server port number to accept requests

request.servervariables["REMOTE_ADDR"]
IP address of the remote host making the request

request.servervariables["Remote_host"]
The name of the remote host that made the request

request.servervariables["LOCAL_ADDR"]
Returns the address of the server accepting the request

request.servervariables["Http_host"]
Return server address

request.servervariables["SERVER_NAME"]
Host name, DNS address, or IP address of the server

request.servervariables["Request_method"]
Methods of making requests such as, post, etc.

request.servervariables["Server_port_secure"]
1 if the server port that accepts the request is a secure port, otherwise 0

request.servervariables["Server_protocol"]
The name and version of the protocol used by the server

request.servervariables["Server_software"]
Name and version of the server software that answered the request and ran the gateway

request.servervariables["All_http"]
All HTTP headers sent by the client, prefixed by HTTP_

request.servervariables["All_raw"]
All HTTP headers sent by the client, with the same results as when the client was sent, without a prefix http_

request.servervariables["Appl_md_path"]
Metabase path for the application

request.servervariables["Content_length"]
The length at which the client emits the content

request.servervariables["Https"]
If the request crosses the secure channel (SSL), returns on if the request is from a non-secure channel, the off

request.servervariables["instance_id"]
ID number of the IIS instance

request.servervariables["Instance_meta_path"]
Metabase path of the IIS instance responding to the request

request.servervariables["Http_accept_encoding"]
Return to content such as: gzip,deflate

request.servervariables["Http_accept_language"]
Back to content such as: en-US

request.servervariables["Http_connection"]
Back to content: keep-alive

request.servervariables["Http_cookie"]
Return to content such as: nvisit%

2dyum=125; Aspsessionidcartqtra=fdobffabjgoecbbkhkgpfiji; Aspsessionidcaqqtsrb=lkjjplababillpcogjgamkam; Aspsessionidacrrssra=dk

Hhhfbbjojcconpphlkghpb

request.servervariables["Http_user_agent"]
Back to content: mozilla/4.0 (compatible; MSIE6.0; WindowsNT5.1; SV1)

request.servervariables["Https_keysize"]
The number of bits of the Secure Sockets Layer connection key, such as 128

request.servervariables["Https_secretkeysize"]
The server verifies the number of bits of the private keyword, such as 1024

request.servervariables["Https_server_issuer"]
Publisher field of the server certificate

request.servervariables["Https_server_subject"]
Subject field of the server certificate

request.servervariables["Auth_password"]
When you use Basic authentication mode, the password that the customer enters in the password dialog box

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 certificate

request.servervariables["Cert_cookie"]
Unique Client Certificate ID number

request.servervariables["Cert_flag"]
Client certificate, if there is a client certificate, BIT0 is 0 if the client certificate validation is not valid, Bit1 is set to 1

request.servervariables["Cert_issuer"]
The Publisher field in the user certificate

request.servervariables["Cert_keysize"]
The number of bits of the Secure Sockets Layer connection key, such as 128

request.servervariables["Cert_secretkeysize"]
The server verifies the number of bits of the private keyword, such as 1024

request.servervariables["Cert_serialnumber"]
Serial Number field for the customer certificate

request.servervariables["Cert_server_issuer"]
Publisher field of the server certificate

request.servervariables["Cert_server_subject"]
Subject field of the server certificate

request.servervariables["Cert_subject"]
The subject field of the client certificate

request.servervariables["Content_Type"]
Data type of form content or httpput sent by the customer

request.servervariables["Http_x_forwarded_for"]
You can get the direct IP that is behind the proxy (gateway), which of course must be supported by this agent


Some of the request.servervariables parameters that are hidden:
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"]


Native ip:<%=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 Time:<%=server.scripttimeout%>


This file path: <%=server.mappath (request.servervariables["Script_name"])%>


Number of server CPUs: <%=request.servervariables["Number_of_processors"]%>


Server Interpreter Engine: <%=scriptengine & "/" & scriptenginemajorversion& "." &ScriptEngineMinorVersion& "." & ScriptEngineBuildVersion%>


Server operating system: <%=request.servervariables["OS"]%>


Supported file types: <%=request.servervariables["Http_accept"]%>


Access file path: <%=request.servervariables["Http_url"]%>


User agent information: <%=request.servervariables["Http_user_agent"]%>

Request.ServerVariables variable meaning. HTTP proxy-related knowledge
request.servervariables["Http_via"]---------can get the internal IP of the user
request.servervariables["Http_x_forwarded_for"]---------can know the server name of the proxy server and the port
request.servervariables["REMOTE_ADDR"]--the IP address of the remote host that made the request.

HTTP Agent-related knowledge
The key is http_x_forwarded_for.
Using different kinds of proxy servers, the information above will be different:

One, not using the proxy server situation:
REMOTE_ADDR = Your IP
Http_via = no value or no display
Http_x_forwarded_for = no value or no display

Second, the use of transparent proxy server situation: Transparent Proxies
REMOTE_ADDR = Proxy Server IP
Http_via = Proxy Server IP
Http_x_forwarded_for = Your real IP
This type of proxy server also forwards your information to your Access object, and does not achieve the purpose of hiding the true identity.

Third, the use of ordinary anonymous proxy server situation: Anonymous Proxies
REMOTE_ADDR = Proxy Server IP
Http_via =

ASP. NET Get customer service IP, server IP

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.