最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Server.MapPath方法的应用方法
时间:2011-06-19 编辑:简简单单 来源:一聚教程网
Server.MapPath方法的应用方法
总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径
1、Server.MapPath("/")
注:获得应用程序根目录所在的位置,如 C:Inetpubwwwroot。
2、Server.MapPath("./")
注:获得所在页面的当前目录,等价于Server.MapPath("")。
3、Server.MapPath("../")
注:获得所在页面的上级目录。
4、Server.MapPath("~/")
注:获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:InetpubwwwrootExample。
./当前目录
/网站主目录
../上层目录
~/网站虚拟目录
如果当前的网站目录为E:wwwroot 应用程序虚拟目录为E:wwwrootcompany 浏览的页面路径为E:wwwrootcompanynewsshow.asp教程
在show.asp页面中使用
Server.MapPath("./") 返回路径为:E:wwwrootcompanynews
Server.MapPath("/") 返回路径为:E:wwwroot
Server.MapPath("../") 返回路径为:E:wwwrootcompany
Server.MapPath("~/") 返回路径为:E:wwwrootcompany
server.MapPath(request.ServerVariables("Path_Info"))
Request.ServerVariables("Path_Translated")
上面两种方式返回路径为 D:wwwrootcompanynewsshow.asp
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10