asp.net-mvc - httpcontext 当前服务器映射路径显示 c :\inetpub\wwwroot when the current location is somewhere else

标签 asp.net-mvc visual-studio-2008 iis mappath

我在 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/

相关文章:

asp.net - 为什么默认情况下不允许 GET 请求返回 JSON?

c# - 为什么这个 AJAX 调用需要这么长时间?

php - 在 Azure Web 角色上设置/获取系统变量

javascript - Kendo MVC 网格过滤器自定义不起作用

asp.net-mvc - 针对 API Controller 创建 View ?

.net - 为什么是 "Evaluation of lambda expressions is not valid in the debugger"?

c# - 如何调试来自 native 代码的 AccessViolationException

c# - 在“属性”窗口中允许多行字符串属性

iis 6 检查是否启用了 ssl 2

asp.net - 可以通过VS2015在IIS中调试/运行ASPNET5应用程序