Get application path without using httpcontext. (asp.net)

Tomasi picture Tomasi · Mar 9, 2010 · Viewed 21.4k times · Source

How to do it?

I don't want to use this:

HttpContext.Current.Server.MapPath

Is there a similar function that I can call without requiring a httpcontext?

For example if a start a thread doing some stuff i cant use the httpcontext, but i still need to get the path of the app. And no i can't pass the context as an argument or read it from a shared var.

Answer

SLaks picture SLaks · Mar 9, 2010

Use the HttpRuntime.AppDomainAppPath property.