It looks like you are using ProcessLongRunningAction in a separate thread.
However, HttpContext.Current will return null if you are not working in the original request stream. This is explained here .
You can use it if you manually set the context for each created stream. This is discussed on similar issues in SO, for example here and here .
However, given the code in your question, it would be better if you just added a parameter for the path in this method, as Johann Blays suggested. You then resolve the path in the original request thread and pass it to this method, which can then be executed in a separate thread. Thus, your method is independent of HttpContext.Current .
source share