執行頁面的Page_Load事件
執行控制項中的Page_Load事件
執行回調事件Button_onclick事件
寫ASP程式的朋友都知道,Request.ServerVariables("SCRIPT_NAME") 返回當前頁面的相對路徑,比如說“http://localhost/bbs/post.asp”,那麼返回的就是“bbs/post.asp
request.servervariables("script_name") 功能是判斷並輸出當前執行檔案的路徑及檔案名稱。 當你變更了asp檔案的名稱的時候,系統會自動適應,方便系統的移植。 如果是指定提交頁面,一旦檔案名稱變了,系統就會出錯。 |
檔案ip路徑:<%="http://" & request.servervariables("server_name")& request.servervariables("script_name") %> <br/>
本機ip:<%=request.servervariables("remote_addr")%> <br/>
伺服器名:<%=Request.ServerVariables("SERVER_NAME")%><br/>
伺服器IP:<%=Request.ServerVariables("LOCAL_ADDR")%><br/>
伺服器連接埠:<%=Request.ServerVariables("SERVER_PORT")%><br/>
伺服器時間:<%=now%><br/>
IIS版本:<%=Request.ServerVariables("SERVER_SOFTWARE")%><br/>
指令碼逾時時間:<%=Server.ScriptTimeout%><br/>
本檔案路徑:<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%><br/>
伺服器CPU數量:<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%><br/>
伺服器解譯引擎:<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."&ScriptEngineBuildVersion %><br/>
伺服器作業系統:<%=Request.ServerVariables("OS")%> <br/>
支援的檔案類型:<%=Request.ServerVariables("HTTP_Accept")%> <br/>
訪問的檔案路徑:<%=Request.ServerVariables("HTTP_url")%> <br/>
使用者代理程式的資訊:<%=Request.ServerVariables("HTTP_USER_AGENT")%> <br/>
擷取url中的檔案名稱和傳過來的值:request.ServerVariables("script_name")+"?"+request.ServerVariableS("QUERY_STRING") <br/>
-----------------------------------------------------------------------------------------------------
產生的如下:
本檔案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/ =====================
類別:常用環境變數 | | 添加到搜藏 | 分享到i貼吧 | 瀏覽(597) | 評論 (0)