Passing site URL to hangfire recurrent jobs

Hi, I have the following situation:
I start up the site, configure hangfire and begin some recurring, long running background jobs which perform some complex DB validations. From within that job, I would like to send an email notifying me of the validation results, and I would like to format the mail with links to the site.
The problem is that at the startup of the job I don’t have a valid HttpContext from which I can get the URL of the site.

Is there any “dignified” solution to the problem besides storing the designated site URL in the project settings?
It’s similar to, which states there is no known site domain without a request context, I am just wondering if there is any design I’m missing which can provide me the needed info.


No, there’s not.

Even when you have a request context, you only know the URL requested by client, but it is not necessary the primary site url.

It is best to assume your background job knows nothing about the web server, hence your options are to store configured URL somewhere (settings file, database etc.), or pass it as one of the arguments when enqueuing/scheduling the job.