I have created a cron job in an API controller in .NET Core 6 as follows:
[HttpGet]
[Route("api/RunMyJob")]
public void RunMyJob()
{
RecurringJob.AddOrUpdate(() => jobmethod(), Cron.DayInterval(5));
}
[NonAction]
public async Task jobmethod()
{
// ........
}
I want to fire this job automatically when the project is run, without calling the API in the browser.
Please check the official doc about Background tasks with hosted services in ASP.NET Core .
Best code examples:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.