RSS
热门关键字:  计算机有关资料  33252  mkv  word  MKV_NT
当前位置 : 主页>建站指南>javascript>列表

ASP.NET与Javascript中获取URL信息

来源: 作者: 时间:2007-12-05 点击:

  我们假设访问这个地址:http://localhost:1351/WebSite1/dir/Default.aspx/adsf?id=12#test  ,下面是各个方法的返回值。

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/adsf?id=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
#test ASP.NET中不能得到#之后的test,因为#不回发页面

  PS:在VS2005中打开WebSite1网站,在浏览器中查看,此时WebSite1为虚拟目录。

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
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册