Access Session Variables from Hangfire

Is it possible to access HttpContext.Current.Cache from a background job in Hangfire? As I understand HttpContext is not accessible so is there a workaround for this?

Which HttpContext or Session exactly would you expect a job to run with?? The execution of a job isn’t tied to a HttpContext (and in my case, they’re not even executed in a web server but a windows service)

Something is not adding up, Session and Cache is not the same.

If you’re running your jobs “in process” with your web app you can access the cache using HostingEnvironment.Cache.

I used HttpRuntime.Cache and that seemed to work just fine :slight_smile: