RLib RLib - 1 month ago 50
ASP.NET (C#) Question

How to use Quartz.NET with ASP.NET Core Web Application?

In traditional

ASP.NET
application, we (re-)intialize the
Quartz.NET
scheduler in the
Application_Start
handler in
global.asax.cs
.
But I have no ideas where to write the code for scheduling jobs as there isn't
global.asax.cs
in
ASP.NET
Core Web application
.
Should I put the code in
Startup.cs
?

Set Set
Answer

You may use ConfigureServices or Configure methods. Although Configure method is mainly used to configure the HTTP request pipeline, the benefit is that you directly can use IHostingEnvironment (and so get configuration settings) and ILoggerFactory interfaces. And using ConfigureServices method those dependencies may be accessed if you create corresponding properties in Startup class.

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)