ASP.NET与Javascript中获取URL地址的各种方法

36 篇文章 1 订阅
20 篇文章 0 订阅

Javascript

Location Property                          Result
location.hash                                 #test
location.host                                   localhost:1351
location.hostname                        localhost
location.href                                    http://localhost:1351/WebSite1/dir/Default.aspx/adsf?id=12#test
location.pathname                        /WebSite1/dir/Default.aspx/adsf
location.port                                   1351
location.protocol                            http:
location.search                              ?id=12

ASP.NET


Request Property                                                                                   Result                                                                                                                                                       Remark
Request.ApplicationPath                                                           /WebSite1                                                                                                                                                 相对于应用程序(而非虚拟目录)根目录的路径
Request.PhysicalApplicationPath    C:/Documents and Settings/wstone.SPANSION/Desktop/WebSite1/                                     

应用程序根目录的物理路径
Request.PhysicalPath  C:/Documents and Settings/wstone.SPANSION/Desktop/WebSite1/dir/Default.aspx       

当前请求的物理路径
Request.PathInfo                                                                                      /adsf                                                                                                                                                             附加的路径信息
Request.RawUrl  /WebSite1/dir/Default.aspx/adsfid=12               前请求相对于应用程序根目录的路径
Request.Url http://localhost:1351/WebSite1/dir/Default.aspx/adsf?id=12   当前请求的完整路径(不包括#之后的)
Request.CurrentExecutionFilePath                       /WebSite1/dir/Default.aspx
Request.FilePath                                                  /WebSite1/dir/Default.aspx
Request.Path                                                       /WebSite1/dir/Default.aspx/adsf
Request.ServerVariables["SERVER_NAME"]                                                                localhost
Request.ServerVariables["SERVER_PORT"]                                                                1351
Request.ServerVariables["SERVER_PORT_SECURE"]                                                   0
Server.MapPath("~")                                                             

C:/Documents and Settings/wstone.SPANSION/Desktop/WebSite1
Server.MapPath("~/")                                                                                                                      

C:/Documents and Settings/wstone.SPANSION/Desktop/WebSite1/
Server.MapPath("~/1.jpg")                                                                                                             

C:/Documents and Settings/wstone.SPANSION/Desktop/WebSite1/1.jpg 
   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值