【问题标题】:How do I get the website root outside of a request?如何在请求之外获取网站根目录?
【发布时间】:2012-09-11 23:08:39
【问题描述】:

在请求中,我可以使用Server.MapPath() 访问网站根目录。如何在不访问Server 的情况下访问该功能或以其他方式获取网站根目录?我正在尝试为 WebActivator.PreApplicationStartMethod 内部的 ninject 建立一个绑定。

我们尝试使用Directory.GetCurrentWorkingDirectory(),它在Microsoft Shared\Dev Server 中返回了一些内容。但是,在Global.asax.cs 中,在Application_Start 中调用Server.MapPath("") 会产生我想要的目录。

【问题讨论】:

    标签: asp.net ninject bootstrapping webactivator


    【解决方案1】:

    使用AppDomain.CurrentDomain.BaseDirectory 返回正确的目录。

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      • 2015-11-12
      • 2011-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多