asp獲取當前路徑語句大全


在asp開發中經常需要用到當前頁面的路徑,相對的,絕對的,有參數的,沒有參數的,這裡整理一下,個人感覺很全的asp獲取頁面路徑語句大全,例如:request.servervariables script_name SERVER_SOFTWARE

文件ip路徑: <%="http://" & request.servervariables("server_name")& request.servervariables("script_name") %>
本機ip: <%=request.servervariables("remote_addr")%>
服務器名: <%=Request.ServerVariables("SERVER_NAME")%>
服務器IP: <%=Request.ServerVariables("LOCAL_ADDR")%>
服務器端口: <%=Request.ServerVariables("SERVER_PORT")%>
服務器時間: <%=now%>
IIS版本: <%=Request.ServerVariables("SERVER_SOFTWARE")%>
腳本超時時間: <%=Server.ScriptTimeout%>
本文件路徑: <%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
服務器CPU數量: <%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
服務器解譯引擎: <%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."&ScriptEngineBuildVersion %>
服務器操作系統: <%=Request.ServerVariables("OS")%>
支持的文件類型: <%=Request.ServerVariables("HTTP_Accept")%>
訪問的文件路徑: <%=Request.ServerVariables("HTTP_url")%>
用戶代理的信息: <%=Request.ServerVariables("HTTP_USER_AGENT")%>
獲取url中的文件名和傳過來的 值:request.ServerVariables("script_name")+"?"+request.ServerVariableS("QUERY_STRING")

---------------------------------------------------------------------------------------------------

產生的如下:
本文件ip路徑:http://localhost/ceshi.asp
本機ip:127.0.0.1
服務器名:localhost
服務器IP:127.0.0.1
服務器端口:8091
服務器時間:2005-7-27 14:28:04
IIS版本:Microsoft-IIS/5.0
腳本超時時間:90
本文件路徑:E:\hospital\ceshi.asp
服務器CPU數量:2
服務器解譯引擎:VBScript/5.6.7426
服務器操作系統:Windows_NT
支持的文件類型:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash,*/*



訪問的文件路徑:/ceshi.asp
用戶代理的信息:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon; COM+ 1.0.2204)
如若獲得此文件的目錄可以利用下面的函數:
<%
Public Function ServerPath
Dim Path
Dim Pos
Path="http://" & Request.ServerVariables("server_name") & Request.ServerVariables("script_name")
Pos=InStrRev(Path,"/")
ServerPath=Left(Path,Pos)
End Function
%>
=====================<br>
所在文件目錄:<%=ServerPath%>
=====================<br>

運行結果為:
所在文件目錄:http://localhost/ =====================

arrow
arrow
    全站熱搜

    waterisme 發表在 痞客邦 留言(0) 人氣()