ASP.NET中获得页面、服务器端信息的有用Request.ServerVariables

来源:互联网 发布:pdf.js php使用教程 编辑:程序博客网 时间:2024/05/16 04:44

 

 

 

常常用到,获得当前页面的IP地址,服务器的IP地址,获得请求页面的路径等,这些得到页面相应信息的Request.ServerVariables参数。于是,使用foreach,把所有的全部列表,请其有用的参数记于此,以供自己和他人便用。

方法:

Request.ServerVariables[
"参数名"]

返回 string类型的值。

参数:

请求的网址:http:
//localhost/hljtcpoa/cpadmin/term_list.aspx?id=5
以下是结果:冒号左边是参数,右边中以上网址的执行结果


APPL_PHYSICAL_PATH: E: et cpoa cpoa

LOCAL_ADDR: 
127.0.0.1

PATH_INFO: 
/hljtcpoa/cpadmin/term_list.aspx

PATH_TRANSLATED: E: et cpoa cpoacpadmin erm_list.aspx

QUERY_STRING: id
=5

REMOTE_ADDR: 
127.0.0.1

REMOTE_HOST: 
127.0.0.1

SCRIPT_NAME: 
/hljtcpoa/cpadmin/term_list.aspx

SERVER_NAME: localhost

SERVER_PORT: 
80

SERVER_SOFTWARE: Microsoft
-IIS/6.0

URL: 
/hljtcpoa/cpadmin/term_list.aspx

HTTP_HOST: localhost

HTTP_REFERER: http:
//localhost/hljtcpoa/cpadmin/term_list.aspx?id=5
//获得上一页的来源,非常有用。