c# - 无法使用 Server.MapPath

标签 c# visual-studio intellisense server.mappath

我必须做什么才能使 Server.MapPath 正常工作?
我有 using System.Web;

还有什么?当我键入 Server 时,Server 没有快速结果选项(智能感知)。

有什么帮助吗?

最佳答案

你可以试试这个

    System.Web.HttpContext.Current.Server.MapPath(path);

或使用HostingEnvironment.MapPath

    System.Web.Hosting.HostingEnvironment.MapPath(path);

关于c# - 无法使用 Server.MapPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11105768/

相关文章:

c# - 将一个数组的每个元素乘以第二个数组的所有元素

javascript - 使用 ajax 在本地主机内将数据从客户端发送到客户端

windows - 尝试在 Visual Studio 2012 中添加对项目的引用, "no items found"

asp.net-mvc - MVC Razor View Intellisense 在 VS 2013/2015/2017 中损坏

visual-studio-2010 - Visual Studio 智能感知和 Lambdas。我怎样才能让它不选择实际类型?

c# - 在 IIS 上工作时 System.Diagnostic.Trace.CorrelationManager.ActivityId 生成为空

c# - 字符串数组也有类似 SubString 或 Split 函数的东西吗?

c# - 如何使用 Xamarin for Visual Studio 在真实的 Android 设备上进行调试?

c++ - VC++2008项目总是 "out of date"

html - 具有自定义 HTML 元素 Intellisense 的 Visual Studio 项目模板