现在的位置: 首页 > 综合 > 正文

如何获取地址栏地址

2013年01月12日 ⁄ 综合 ⁄ 共 3430字 ⁄ 字号 评论关闭

获取地址栏信息

 

第一种:

http://www.test.com/testweb/default.aspx

Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx

 

 

第二种:

RawUrl
属性属性值当前请求的原始 URL。
备注

原始 URL 定义为 URL 中域信息之后的部分。在 URL 字符串 http://www.pageadmin.net/cn/introduct/lanmu_24_57.html中,原始 URL 为/cn/introduct/lanmu_24_57.html。原始 URL 包括查询字符串(如果存在)。

测试的url地址是http://www.test.com/testweb/default.aspx?id=1, 结果如下:

Request.ApplicationPath: /testweb

Request.CurrentExecutionFilePath: /testweb/default.aspx

Request.FilePath: /testweb/default.aspx

Request.Path: /testweb/default.aspx

Request.PathInfo:

Request.PhysicalApplicationPath: E:\WWW\testweb\

Request.PhysicalPath: E:\WWW\testweb\default.aspx

Request.RawUrl: /testweb/default.aspx?id=1

Request.Url.AbsolutePath: /testweb/default.aspx

Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx?id=1

Request.Url.Host: www.test.com

Request.Url.LocalPath: /testweb/default.aspx

 
 
第三种:
ASP获取方法
 
如果要想获取这样的地址:[url=http://192.168.0.5/super/super_article.asp?id=4]http://192.168.0.5/super/super_article.asp?id=4[/url]
        那么我们就只要获取:
        192.168.0.5---><%=Request.ServerVariables("HTTP_HOST")%>
        /super/super_article.asp-----><%=Request.ServerVariables("URL")%>
        id=4----><%=Request.ServerVariables("QUERY_STRING")%>
        那么我们把上面的地址合起来就可以完成任务了:
        [url=http://192.168.0.5/super/super_article.asp?id=4-----]http://192.168.0.5/super/super_article.asp?id=4----->;http://<;%=Request.ServerVariables("HTTP_HOST")&request.ServerVariables("URL")&"?"&Request.ServerVariables("QUERY_STRING[/url]") %>
使用获取url中的文件名和传过来的值:
本文件ip路径:<%="http://" & request.servervariables("server_name")&request.servervariables("script_name") %>
就可以了..
下面是具体其它一些获取服务器信息的一些方法
几个常用Request.ServerVariables的中文
本文件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")%>
[url=http://www.niuniujidi.org]妞妞基地[/url]服务器时间:<%=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")
ASP:[url=http://www.caoliu-caoliu.cn]***[/url]如何获取文件所在目录
在ASP中,我们都知道文件的路径怎么获取,但是文件所在目录却不知道怎么办?
我们获取文件的路径是:<%=Request.ServerVariables("PATH_TRANSLATED")%>
既然我们都获取了文件的路径了,那么我们就可以使用函数来处理一下刚才获取的路径,
下面就是我们的处理:
<%=Left(Request.ServerVariables("PATH_TRANSLATED"),instrRev(Request.ServerVariables("PATH_TRANSLATED"),"\"))%>
那么这个输出是什么呢?它就是你要的文件所在的目录路径。
此教程来源于97xxoo教程网([url=http://www.97xxoo.org]97xxoo[/url])查看完整的教程请点:[url=http://97xxoo.org/article/2/2008/20081111314.shtml]http://97xxoo.org/article/2/2008/20081111314.shtml[/url]

 

抱歉!评论已关闭.