参考代码 |
功能描述 |
运行结果 |
HttpContext.Current.Request.Url |
获取网址 |
https://www.szeight.com/code/aspx/Request.aspx |
HttpContext.Current.Request.Url.Host |
获取域名 |
www.szeight.com |
HttpContext.Current.Request.Url.Query |
获取参数 |
|
HttpContext.Current.Request.UserHostAddress |
获取客户端IP地址 |
111.173.76.198 |
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] |
获取客户端IP地址 |
111.173.76.198 |
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] |
获取客户端IP地址,无视代理。 |
|
HttpContext.Current.Request.ServerVariables["ALL_HTTP"] |
客户端发送的所有HTTP标头,他的结果都有前缀HTTP_ |
测试关闭 |
HttpContext.Current.Request.ServerVariables["ALL_RAW"] |
客户端发送的所有HTTP标头,其结果和客户端发送时一样,没有前缀HTTP_ |
测试关闭 |
HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"] |
应用程序的元数据库路径。 |
测试关闭 |
HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"] |
与应用程序元数据库路径相应的物理路径。 |
测试关闭 |
HttpContext.Current.Request.ServerVariables["CONTENT_LENGTH"] |
客户端发出内容的长度。 |
0 |
HttpContext.Current.Request.ServerVariables["CONTENT_TYPE"] |
客户发送的form内容或HTTP PUT的数据类型。 |
|
HttpContext.Current.Request.ServerVariables["GATEWAY_INTERFACE"] |
服务器使用的网关界面。 |
CGI/1.1 |
HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"] |
返回接受请求的服务器地址。 |
101.36.223.170 |
HttpContext.Current.Request.ServerVariables["PATH_INFO"] |
客户端提供的路径信息。 |
/code/aspx/Request.aspx |
HttpContext.Current.Request.ServerVariables["PATH_TRANSLATED"] |
通过由虚拟至物理的映射后得到的路径。 |
测试关闭 |
HttpContext.Current.Request.ServerVariables["QUERY_STRING"] |
查询字符串内容。 |
|
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] |
发出请求的远程主机的IP地址。 |
111.173.76.198 |
HttpContext.Current.Request.ServerVariables["REMOTE_HOST"] |
发出请求的远程主机名称。 |
111.173.76.198 |
HttpContext.Current.Request.ServerVariables["REQUEST_METHOD"] |
提出请求的方法。比如GET、HEAD、POST等等。 |
GET |
HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"] |
执行脚本的名称。 |
/code/aspx/Request.aspx |
HttpContext.Current.Request.ServerVariables["SERVER_NAME"] |
服务器的主机名、DNS地址或IP地址。 |
www.szeight.com |
HttpContext.Current.Request.ServerVariables["SERVER_PORT"] |
接受请求的服务器端口号。 |
443 |
HttpContext.Current.Request.ServerVariables["SERVER_PORT_SECURE"] |
如果接受请求的服务器端口为安全端口时,则为1,否则为0。 |
1 |
HttpContext.Current.Request.ServerVariables["SERVER_PROTOCOL"] |
服务器使用的协议的名称和版本。 |
HTTP/1.1 |
HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"] |
应答请求并运行网关的服务器软件的名称和版本。 |
Microsoft-IIS/10.0 |
HttpContext.Current.Request.ServerVariables["URL"] |
提供URL的基本部分。 |
/code/aspx/Request.aspx |