I see a lot of solutions here but they area already outdated. Is there a new approach? It's something about the Ijobfactory.
public class JobBase : IJob
{
private readonly ILogger _logger;
public JobBase(ILogger logger)
{
_logger = logger;
}
public void Initialize()
{
// Create fake httpcontext
HttpContext.Current = new HttpContext(
new HttpRequest(null, "[localhost]", ""),
new HttpResponse(new StreamWriter(new MemoryStream())));
}
public virtual void Execute(IJobExecutionContext context)
{
}
}
Found it, you can actually use dependencyresolver to implement a class in the quartz class. It worked for my project.