首页 > 开发 > Asp > 正文

ASP的Server.MapPath()不同参数返回路径总结

2020-06-20 14:00:51
字体:
来源:转载
供稿:网友

在使用Server.MapPath()的时候,有很多的参数,什么绝对路径啊,相对路径啊,这些不复杂但是很容易弄混淆的东西,这里将他做一个整理。

复制代码 代码如下:

./当前目录
/网站主目录
../上层目录
~/网站虚拟目录

如果当前的网站目录为E:/wwwroot
应用程序虚拟目录为E:/wwwroot/company
浏览的页面路径为E:/wwwroot/company/news/show.asp
在show.asp页面中使用

复制代码 代码如下:

Server.MapPath(“./”) 返回路径为:E:/wwwroot/company/news
Server.MapPath(“/”) 返回路径为:E:/wwwroot
Server.MapPath(“../”) 返回路径为:E:/wwwroot/company
Server.MapPath(“~/”) 返回路径为:E:/wwwroot/company

server.MapPath(request.ServerVariables(“Path_Info”))
Request.ServerVariables(“Path_Translated”)
上面两种方式返回路径为 D:/wwwroot/company/news/show.asp

您可能感兴趣的文章:

server.mappath方法详解ASP.NET获取各级目录Server.MapPath详解全asp.net Server.MapPath方法注意事项有关Server.Mappath详细接触
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表