最近在做相关的开发,碰到了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
  • 如果当前的网站目录为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

相关文章:

  • 2022-01-05
  • 2021-07-16
  • 2021-05-08
  • 2022-01-01
  • 2021-07-23
  • 2021-07-01
  • 2021-05-01
  • 2021-05-23
猜你喜欢
  • 2021-10-30
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案