Alternative for missing HttpContent

Hi Sergey,

I’m very impressed with the HangFire! Its simplicity, power and beautiful dashboard are awesome! Congratulations! =D

But I’m having a problem trying use Rotativa to generate PDF attachment to a email. The “BuildPdf” method (https://github.com/webgio/Rotativa/issues/19) ask for a ControllerContext, which is not available in the jobs context.

My ask is if HangFire has any extensibility point to create jobs that can access to ControllerContext like a normal MVC controller. Or yet, any tip for generate PDFs from razor in the background jobs.

My enqueue pseudo-code:
BackgroundJob.Enqueue<‘MailController’>(controller => controller.MyPdfsAction(mail.Id));

Anyway, many thanks for share this really awesome project!
Cheers from Brasil! o/

Hello @oliveiracdz! Thank you for good words, and sorry for the delay!

All background jobs are being executed outside of the request processing pipeline, and this is the goal of the project. Unfortunately, some libraries for ASP.NET projects are not prepared to be executed outside of HTTP request scope.

There is a possibility to capture the HttpContext.Current property and deserialize it before background job invocation (as in CaptureCultureAttribute), but a lot of things will be unavailable, such as current user, response, cookies, etc, and this will lead to strange errors.

I really hope that library authors will make two versions of their libraries – core library, and ASP.NET wrapper library.

From Russia with love :smile: