Server.MapPath()目录详解

最近在做相关的开发,碰到了Server.MapPath(),顺便来温习一下
Server.MapPath()获取网站的目录详解 
  1. ./当前目录
  2. /网站主目录
  3. ../上层目录
  4. ~/网站虚拟目录
  • 如果当前的网站目录为E:www123,应用程序虚拟目录为E:www123wlj ,浏览的页面路径为E:www123wljhahaheihei.asp。
  • 例子:heihei.asp页面中的具体使用如下
  • Server.MapPath("./")   返回路径为:E:www123wljhaha
  • Server.MapPath("/")    返回路径为:E:www123
  • Server.MapPath("../")   返回路径为:E:www123wlj
  • Server.MapPath("~/")   返回路径为:E:www123wlj
  • server.MapPath(request.ServerVariables("Path_Info")) 
  • Request.ServerVariables("Path_Translated") 
  • 上面两种方式返回路径为 D:www123wljhahaheihei.asp
原文地址:https://www.cnblogs.com/1175429393wljblog/p/5497065.html