It’s possible to use HostingEnvironment.MapPath() instead of HttpContext.Current.Server.MapPath()
I haven’t tried it yet in a thread or timer event though.
Some (non viable) solutions I considered;
-
The only method I care about on
HttpServerUtilityisMapPath. So as an alternative I could useAppDomain.CurrentDomain.BaseDirectoryand build my paths from this. But this will fail if your app uses virtual directories (Mine does). -
Another approach:
Add all the paths I need to the theGlobalclass. Resolve these paths inApplication_Start.