<分区>
我有自己的 siteMapProvider,我需要物理文件路径来初始化它,但我不能使用 HttpContext 来做到这一点,因为 IIS 7 会抛出异常:
fileName = HttpContext.Current.Server.MapPath(fileName);
没有 HttpContext 我如何做 MapPath?
标签 c# asp.net-mvc
<分区>
我有自己的 siteMapProvider,我需要物理文件路径来初始化它,但我不能使用 HttpContext 来做到这一点,因为 IIS 7 会抛出异常:
fileName = HttpContext.Current.Server.MapPath(fileName);
没有 HttpContext 我如何做 MapPath?
最佳答案
请查看以下内容:HttpRuntime.AppDomainAppPath (来自MSDN)
关于c# - 如何获取 ASP.NET 应用程序路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5233735/
相关文章:
c# - "Could not load file or assembly"错误。可以在我的电脑上运行,但不能在其他电脑上运行
c# - 如何将 html 绑定(bind)到 rdlc 文件
asp.net - 上传 - MVC3 : HTTP 302 Redirect Error (due to asp. 网络身份验证)
asp.net-mvc - Razor - 在没有 Render() 和没有编码的情况下渲染
asp.net-mvc - 从 MVC 中的 _Layout.cshtml 中的 Ninject 获取对象实例
c# - Windows 身份基础系统.Xml.XmlException : Unexpected end of file