问题
I wish to send an email in a scheduled timeline (once in a week) from my MVC website. The code is working perfectly fine on the scheduled time when running through Visual Studio locally. However, not getting triggered after deployment to the server.
It starts working when I hit the website once after deployment,as the Applciaiton_Start event gets fired where I trigger the Quartz engine.
Is there a way by which I can trigger the engine without visiting the website even once. Does Quartz always work this way, that you have to hit the Application once.
回答1:
No, you can't.
Quartz.net, in your situation, lives inside your application.
When the Application Pool gets recycled your scheduler dies.
This is not a problem with Quartz.Net but IIS and the way it managed the application pool.
I guess the best option for you is to use the scheduler in Windows Service.
Another option is to create a simple application (console) and run it through the System Task Scheduler. With this option you might want to get rid of Quartz.Net.
Third option is to keep your application alive using some external service like Uptime Robot or Pingdom. I wouldn't choose this option but it's one possibility.
If you're going for the 3rd option I would advice you to use the JobStore so you can persist your job in a database and you don't miss the fires.
来源:https://stackoverflow.com/questions/31943610/quartz-net-scheduled-code-not-working-after-deployment-automatically-working-l