Downloading a file that was created by a background job


#1

My web app currently needs to build an excel file from the contents of a given model. This usually takes a lot of time especially when there are a lot of entries on the said model. This is why I decided to try out Hangfire.

I’ve been successful on getting the job to run in background to build the excel file but I realized that I cannot use HttpResponse from inside the job to trigger a download on the user’s browser to receive the created file.

Is there already a best practice on how to approach this? I was thinking that I needed to save this file on a separate model and then use something like SignalR to notify my web app that the job is finished. The app would then look for the file on the database and prompt the download from there.

I just wanted to check on here if anyone has thought of another way of achieving this.

Thanks!