Server.MapPath()目录详解

最近在做相关的开发,碰到了Server.MapPath(),顺便来温习一下
Server.MapPath()获取网站的目录详解 
  1. ./当前目录
  2. /网站主目录
  3. ../上层目录
  4. ~/网站虚拟目录
  • 如果当前的网站目录为E:\www123,应用程序虚拟目录为E:\www123\wlj ,浏览的页面路径为E:\www123\wlj\haha\heihei.asp。
  • 例子:heihei.asp页面中的具体使用如下
  • Server.MapPath("./")   返回路径为:E:\www123\wlj\haha
  • Server.MapPath("/")    返回路径为:E:\www123
  • Server.MapPath("../")   返回路径为:E:\www123\wlj
  • Server.MapPath("~/")   返回路径为:E:\www123\wlj
  • server.MapPath(request.ServerVariables("Path_Info")) 
  • Request.ServerVariables("Path_Translated") 
  • 上面两种方式返回路径为 D:\www123\wlj\haha\heihei.asp
posted @ 2016-05-16 09:49  龙骑科技  阅读(535)  评论(0编辑  收藏  举报