I have some processes that run without an HttpContext in an ASP.NET MVC web application. This process needs to be able to determine the physical path to the Contents directory of the application for reading/writing data. But, since it is without an HttpContext, I don’t get to use fancy things like Server.MapPath and such. Suggestions?
Share
In a website, it is best to use
HttpRuntime.AppDomainAppPath, because in certain moments of the execution path (i.e. when the site starts up), there’s noHttpContext.Currentavailable.See also this post.