Using MapPath from a worker thread
Asked Answered
B

2

19

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?

Bornie answered 24/2, 2010 at 23:8 Comment(0)
B
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.

Bornie answered 25/2, 2010 at 18:5 Comment(0)
P
45

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

No HttpContext required and it does the same work.

Pig answered 18/1, 2011 at 21:3 Comment(0)
B
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.

Bornie answered 25/2, 2010 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.