Question

I have a WCF service method that's running in a worker thread I spin from another method.
I need to map a relative service app path ("~/Templates/a.template") to the physical path ("D:\Web\Templates\a.template"), but I can't use HttpContext.Current.Server.MapPath because HttpContext.Current is null in a worker thread. How else can I reach MapPath method?

Thanks! Andrey

Was it helpful?

Solution 2

I actually figured out a workaround - I use HostingEnvironment.ApplicationPath to get physical path of WCF service, and add the relative path to it.

OTHER TIPS

Use System.Web.Hosting.HostingEnvironment.MapPath().

No HttpContext required and it does the same work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top