如何获取ASP.NET应用程序路径?

我有自己拥有的siteMapProvider,我需要phisical文件路径来初始化它,但我不能使用HttpContext来做到这一点,因为IIS 7将抛出exception:

fileName = HttpContext.Current.Server.MapPath(fileName); 

如何在没有HttpContext的情况下执行MapPath?

看一下以下内容: HttpRuntime.AppDomainAppPath (来自MSDN)

你也可以尝试:

 HttpContext.Current.Request.PhysicalApplicationPath