asp.net Request.ServerVariables[] 讀解
更新時間:2011年08月19日 13:26:15 作者:
asp.net Request.ServerVariables[] 讀解,學(xué)習(xí).net的朋友可以參考下,方便獲取服務(wù)器的一些信息。
獲取客戶端的IP地址,代碼如下:
/// <summary>
/// 獲取客戶端IP地址
/// </summary>
/// <returns></returns>
public string GetClientIP()
{
string userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (userIP == null)
userIP = Request.ServerVariables["REMOTE_ADDR"];
return userIP;
}
名詞解釋: ServerVariables -- 服務(wù)器變量
Request.ServerVariables("Url")
返回服務(wù)器地址
Request.ServerVariables("Path_Info")
客戶端提供的路徑信息
Request.ServerVariables("Appl_Physical_Path")
與應(yīng)用程序元數(shù)據(jù)庫路徑相應(yīng)的物理路徑
Request.ServerVariables("Path_Translated")
通過由虛擬至物理的映射后得到的路徑
Request.ServerVariables("Script_Name")
執(zhí)行腳本的名稱
Request.ServerVariables("Query_String")
查詢字符串內(nèi)容
Request.ServerVariables("Http_Referer")
請求的字符串內(nèi)容
Request.ServerVariables("Server_Port")
接受請求的服務(wù)器端口號
Request.ServerVariables("Remote_Addr")
發(fā)出請求的遠(yuǎn)程主機的IP地址
Request.ServerVariables("Remote_Host")
發(fā)出請求的遠(yuǎn)程主機名稱
Request.ServerVariables("Local_Addr")
返回接受請求的服務(wù)器地址
Request.ServerVariables("Http_Host")
返回服務(wù)器地址
Request.ServerVariables("Server_Name")
服務(wù)器的主機名、DNS地址或IP地址
Request.ServerVariables("Request_Method")
提出請求的方法比如GET、HEAD、POST等等
Request.ServerVariables("Server_Port_Secure")
如果接受請求的服務(wù)器端口為安全端口時,則為1,否則為0
Request.ServerVariables("Server_Protocol")
服務(wù)器使用的協(xié)議的名稱和版本
Request.ServerVariables("Server_Software")
應(yīng)答請求并運行網(wǎng)關(guān)的服務(wù)器軟件的名稱和版本
Request.ServerVariables("All_Http")
客戶端發(fā)送的所有HTTP標(biāo)頭,前綴HTTP_
Request.ServerVariables("All_Raw")
客戶端發(fā)送的所有HTTP標(biāo)頭,其結(jié)果和客戶端發(fā)送時一樣,沒有前綴HTTP_
Request.ServerVariables("Appl_MD_Path")
應(yīng)用程序的元數(shù)據(jù)庫路徑
Request.ServerVariables("Content_Length")
客戶端發(fā)出內(nèi)容的長度
Request.ServerVariables("Https")
如果請求穿過安全通道(SSL),則返回ON如果請求來自非安全通道,則返回OFF
Request.ServerVariables("Instance_ID")
IIS實例的ID號
Request.ServerVariables("Instance_Meta_Path")
響應(yīng)請求的IIS實例的元數(shù)據(jù)庫路徑
Request.ServerVariables("Http_Accept_Encoding")
返回內(nèi)容如:gzip,deflate
Request.ServerVariables("Http_Accept_Language")
返回內(nèi)容如:en-us
Request.ServerVariables("Http_Connection")
返回內(nèi)容:Keep-Alive
Request.ServerVariables("Http_Cookie")
返回內(nèi)容如:nVisiT%
2DYum=125;ASPSESSIONIDCARTQTRA=FDOBFFABJGOECBBKHKGPFIJI;ASPSESSIONIDCAQQTSRB=LKJJPLABABILLPCOGJGAMKAM;ASPSESSIONIDACRRSSRA=DK
HHHFBBJOJCCONPPHLKGHPB
Request.ServerVariables("Http_User_Agent")
返回內(nèi)容:Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.1;SV1)
Request.ServerVariables("Https_Keysize")
安全套接字層連接關(guān)鍵字的位數(shù),如128
Request.ServerVariables("Https_Secretkeysize")
服務(wù)器驗證私人關(guān)鍵字的位數(shù)如1024
Request.ServerVariables("Https_Server_Issuer")
服務(wù)器證書的發(fā)行者字段
Request.ServerVariables("Https_Server_Subject")
服務(wù)器證書的主題字段
Request.ServerVariables("Auth_Password")
當(dāng)使用基本驗證模式時,客戶在密碼對話框中輸入的密碼
Request.ServerVariables("Auth_Type")
是用戶訪問受保護(hù)的腳本時,服務(wù)器用於檢驗用戶的驗證方法
Request.ServerVariables("Auth_User")
代證的用戶名
Request.ServerVariables("Cert_Cookie")
唯一的客戶證書ID號
Request.ServerVariables("Cert_Flag")
客戶證書標(biāo)誌,如有客戶端證書,則bit0為0如果客戶端證書驗證無效,bit1被設(shè)置為1
Request.ServerVariables("Cert_Issuer")
用戶證書中的發(fā)行者字段
Request.ServerVariables("Cert_Keysize")
安全套接字層連接關(guān)鍵字的位數(shù),如128
Request.ServerVariables("Cert_Secretkeysize")
服務(wù)器驗證私人關(guān)鍵字的位數(shù)如1024
Request.ServerVariables("Cert_Serialnumber")
客戶證書的序列號字段
Request.ServerVariables("Cert_Server_Issuer")
服務(wù)器證書的發(fā)行者字段
Request.ServerVariables("Cert_Server_Subject")
服務(wù)器證書的主題字段
Request.ServerVariables("Cert_Subject")
客戶端證書的主題字段
Request.ServerVariables("Content_Type")
客戶發(fā)送的form內(nèi)容或HTTPPUT的數(shù)據(jù)類型
Request.ServerVariables("HTTP_X_FORWARDED_FOR")
可以獲得位于代理(網(wǎng)關(guān))后面的直接IP,當(dāng)然必須這個代理支持
一些被隱藏起來的Request.ServerVariables參數(shù):
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")
本機ip:<%=request.servervariables("remote_addr")%>
服務(wù)器名:<%=Request.ServerVariables("SERVER_NAME")%>
服務(wù)器IP:<%=Request.ServerVariables("LOCAL_ADDR")%>
服務(wù)器端口:<%=Request.ServerVariables("SERVER_PORT")%>
服務(wù)器時間:<%=now%>
IIS版本:<%=Request.ServerVariables("SERVER_SOFTWARE")%>
腳本超時時間:<%=Server.ScriptTimeout%>
本文件路徑:<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
服務(wù)器CPU數(shù)量:<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
服務(wù)器解譯引擎:<%=ScriptEngine & "/"& ScriptEngineMajorVersion&"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
服務(wù)器操作系統(tǒng):<%=Request.ServerVariables("OS")%>
支持的文件類型:<%=Request.ServerVariables("HTTP_Accept")%>
訪問的文件路徑:<%=Request.ServerVariables("HTTP_url")%>
用戶代理的信息:<%=Request.ServerVariables("HTTP_USER_AGENT")%>
復(fù)制代碼 代碼如下:
/// <summary>
/// 獲取客戶端IP地址
/// </summary>
/// <returns></returns>
public string GetClientIP()
{
string userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (userIP == null)
userIP = Request.ServerVariables["REMOTE_ADDR"];
return userIP;
}
名詞解釋: ServerVariables -- 服務(wù)器變量
Request.ServerVariables("Url")
返回服務(wù)器地址
Request.ServerVariables("Path_Info")
客戶端提供的路徑信息
Request.ServerVariables("Appl_Physical_Path")
與應(yīng)用程序元數(shù)據(jù)庫路徑相應(yīng)的物理路徑
Request.ServerVariables("Path_Translated")
通過由虛擬至物理的映射后得到的路徑
Request.ServerVariables("Script_Name")
執(zhí)行腳本的名稱
Request.ServerVariables("Query_String")
查詢字符串內(nèi)容
Request.ServerVariables("Http_Referer")
請求的字符串內(nèi)容
Request.ServerVariables("Server_Port")
接受請求的服務(wù)器端口號
Request.ServerVariables("Remote_Addr")
發(fā)出請求的遠(yuǎn)程主機的IP地址
Request.ServerVariables("Remote_Host")
發(fā)出請求的遠(yuǎn)程主機名稱
Request.ServerVariables("Local_Addr")
返回接受請求的服務(wù)器地址
Request.ServerVariables("Http_Host")
返回服務(wù)器地址
Request.ServerVariables("Server_Name")
服務(wù)器的主機名、DNS地址或IP地址
Request.ServerVariables("Request_Method")
提出請求的方法比如GET、HEAD、POST等等
Request.ServerVariables("Server_Port_Secure")
如果接受請求的服務(wù)器端口為安全端口時,則為1,否則為0
Request.ServerVariables("Server_Protocol")
服務(wù)器使用的協(xié)議的名稱和版本
Request.ServerVariables("Server_Software")
應(yīng)答請求并運行網(wǎng)關(guān)的服務(wù)器軟件的名稱和版本
Request.ServerVariables("All_Http")
客戶端發(fā)送的所有HTTP標(biāo)頭,前綴HTTP_
Request.ServerVariables("All_Raw")
客戶端發(fā)送的所有HTTP標(biāo)頭,其結(jié)果和客戶端發(fā)送時一樣,沒有前綴HTTP_
Request.ServerVariables("Appl_MD_Path")
應(yīng)用程序的元數(shù)據(jù)庫路徑
Request.ServerVariables("Content_Length")
客戶端發(fā)出內(nèi)容的長度
Request.ServerVariables("Https")
如果請求穿過安全通道(SSL),則返回ON如果請求來自非安全通道,則返回OFF
Request.ServerVariables("Instance_ID")
IIS實例的ID號
Request.ServerVariables("Instance_Meta_Path")
響應(yīng)請求的IIS實例的元數(shù)據(jù)庫路徑
Request.ServerVariables("Http_Accept_Encoding")
返回內(nèi)容如:gzip,deflate
Request.ServerVariables("Http_Accept_Language")
返回內(nèi)容如:en-us
Request.ServerVariables("Http_Connection")
返回內(nèi)容:Keep-Alive
Request.ServerVariables("Http_Cookie")
返回內(nèi)容如:nVisiT%
2DYum=125;ASPSESSIONIDCARTQTRA=FDOBFFABJGOECBBKHKGPFIJI;ASPSESSIONIDCAQQTSRB=LKJJPLABABILLPCOGJGAMKAM;ASPSESSIONIDACRRSSRA=DK
HHHFBBJOJCCONPPHLKGHPB
Request.ServerVariables("Http_User_Agent")
返回內(nèi)容:Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.1;SV1)
Request.ServerVariables("Https_Keysize")
安全套接字層連接關(guān)鍵字的位數(shù),如128
Request.ServerVariables("Https_Secretkeysize")
服務(wù)器驗證私人關(guān)鍵字的位數(shù)如1024
Request.ServerVariables("Https_Server_Issuer")
服務(wù)器證書的發(fā)行者字段
Request.ServerVariables("Https_Server_Subject")
服務(wù)器證書的主題字段
Request.ServerVariables("Auth_Password")
當(dāng)使用基本驗證模式時,客戶在密碼對話框中輸入的密碼
Request.ServerVariables("Auth_Type")
是用戶訪問受保護(hù)的腳本時,服務(wù)器用於檢驗用戶的驗證方法
Request.ServerVariables("Auth_User")
代證的用戶名
Request.ServerVariables("Cert_Cookie")
唯一的客戶證書ID號
Request.ServerVariables("Cert_Flag")
客戶證書標(biāo)誌,如有客戶端證書,則bit0為0如果客戶端證書驗證無效,bit1被設(shè)置為1
Request.ServerVariables("Cert_Issuer")
用戶證書中的發(fā)行者字段
Request.ServerVariables("Cert_Keysize")
安全套接字層連接關(guān)鍵字的位數(shù),如128
Request.ServerVariables("Cert_Secretkeysize")
服務(wù)器驗證私人關(guān)鍵字的位數(shù)如1024
Request.ServerVariables("Cert_Serialnumber")
客戶證書的序列號字段
Request.ServerVariables("Cert_Server_Issuer")
服務(wù)器證書的發(fā)行者字段
Request.ServerVariables("Cert_Server_Subject")
服務(wù)器證書的主題字段
Request.ServerVariables("Cert_Subject")
客戶端證書的主題字段
Request.ServerVariables("Content_Type")
客戶發(fā)送的form內(nèi)容或HTTPPUT的數(shù)據(jù)類型
Request.ServerVariables("HTTP_X_FORWARDED_FOR")
可以獲得位于代理(網(wǎng)關(guān))后面的直接IP,當(dāng)然必須這個代理支持
一些被隱藏起來的Request.ServerVariables參數(shù):
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")
本機ip:<%=request.servervariables("remote_addr")%>
服務(wù)器名:<%=Request.ServerVariables("SERVER_NAME")%>
服務(wù)器IP:<%=Request.ServerVariables("LOCAL_ADDR")%>
服務(wù)器端口:<%=Request.ServerVariables("SERVER_PORT")%>
服務(wù)器時間:<%=now%>
IIS版本:<%=Request.ServerVariables("SERVER_SOFTWARE")%>
腳本超時時間:<%=Server.ScriptTimeout%>
本文件路徑:<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
服務(wù)器CPU數(shù)量:<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
服務(wù)器解譯引擎:<%=ScriptEngine & "/"& ScriptEngineMajorVersion&"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
服務(wù)器操作系統(tǒng):<%=Request.ServerVariables("OS")%>
支持的文件類型:<%=Request.ServerVariables("HTTP_Accept")%>
訪問的文件路徑:<%=Request.ServerVariables("HTTP_url")%>
用戶代理的信息:<%=Request.ServerVariables("HTTP_USER_AGENT")%>
您可能感興趣的文章:
- ServerVariables集合檢索預(yù)定的環(huán)境變量
- php Undefined index和Undefined variable的解決方法
- you *might* want to use the less safe log_bin_trust_function_creators variable
- PHP提示Notice: Undefined variable的解決辦法
- 使用c++11打造好用的variant方法
- MariaDB(Mysql分支)my.cnf配置文件中文注釋版
- 淺談MySQL和mariadb區(qū)別
- 詳解Bootstrap的aria-label和aria-labelledby應(yīng)用
相關(guān)文章
vs2010根據(jù)字符串內(nèi)容添加斷點的方法介紹
這篇文章介紹了vs2010根據(jù)字符串內(nèi)容添加斷點的方法,有需要的朋友可以參考一下2013-08-08推薦8項提高 ASP.NET Web API 性能的技術(shù)
ASP.NET Web API 是非常棒的技術(shù)。編寫 Web API 十分容易,以致于很多開發(fā)者沒有在應(yīng)用程序結(jié)構(gòu)設(shè)計上花時間來獲得很好的執(zhí)行性能。2014-08-08asp.net?core?中的Jwt(Json?Web?Token)的使用詳解
session不支持分布式并且在服務(wù)器存儲一份用戶登錄的信息,這份登錄信息會在響應(yīng)時傳遞給瀏覽器,告訴其保存為cookie,以便下次請求時發(fā)送給我們的應(yīng)用,這篇文章主要介紹了asp.net?core?中的Jwt(Json?Web?Token)的使用,需要的朋友可以參考下2022-10-10ASP.NET實現(xiàn)讀取Excel內(nèi)容并在Web上顯示
這篇文章主要介紹了ASP.NET實現(xiàn)讀取Excel內(nèi)容并在Web上顯示,很實用的一個技巧,需要的朋友可以參考下2014-08-08Asp.Net?Core?使用Monaco?Editor?實現(xiàn)代碼編輯器功能
在項目中經(jīng)常有代碼在線編輯的需求,比如修改基于Xml的配置文件,編輯Json格式的測試數(shù)據(jù)等。這篇文章主要介紹了Asp.Net?Core?使用Monaco?Editor?實現(xiàn)代碼編輯器功能,需要的朋友可以參考下2022-01-01asp.net中使用cookie與md5加密實現(xiàn)記住密碼功能的實現(xiàn)代碼
雖然.net內(nèi)置了登陸控件,有記住密碼的功能,但還是想自己實踐一下,以下代碼主要應(yīng)用了COOKIE,包括安全加密的過程等2013-02-02