我在 VS 2008 中接手了另一个开发人员的 MVC 项目,我需要知道为什么 HttpContext.Current.Server.MapPath("/")
是 c:\inetpub\wwwroot
。
我正在从c:\Websites\Customer\Web\Website\Application\
运行该项目
IIS 显示该站点正在从:c:\Websites\Customer\Web\Website\Application\
运行,所以我非常困惑。
有什么想法吗?
最佳答案
使用Server.MapPath("~")
,它返回应用程序根目录的物理路径。
您使用的Server.MapPath("/")
返回域根的物理路径。
关于asp.net-mvc - httpcontext 当前服务器映射路径显示 c :\inetpub\wwwroot when the current location is somewhere else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17843366/