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?
Asked
Active
Viewed 4,653 times
19
Andrey
- 20,487
- 26
- 108
- 176
2 Answers
44
Use System.Web.Hosting.HostingEnvironment.MapPath().
No HttpContext required and it does the same work.
Hakan Fıstık
- 16,800
- 14
- 110
- 131
mas_oz2k1
- 2,851
- 3
- 34
- 41
-
Ha...I've never come across that before. Thanks. – Lee Gunn Oct 11 '12 at 09:11
5
I actually figured out a workaround - I use HostingEnvironment.ApplicationPath to get physical path of WCF service, and add the relative path to it.
Andrey
- 20,487
- 26
- 108
- 176