知识库

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

来源: 本站    类别: 知识库    日期: 2015/5/2

 

在使用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


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com