Httpcontext in hangfirejob

I need to set httpcontext.current.session with connection string in hangfire job for customer in muilti talent so i can connect to customer db when exceute the job

1 Like

Hangfire jobs should not rely on HttpContext - the jobs are not run in the context of a HTTP request, so HttpContext.Current will be null. If you need a connection string, pass it as a parameter when scheduling the job.

1 Like

Hangfire Jobs should not rely on HTTP Context, because they will come from a different path. Simply pass HTTP Context required values as a parameter in the function which is going to be called from background job.