Cannot keep alive Web Application on IIS after Recycling or Restarting

倾然丶 夕夏残阳落幕 提交于 2019-11-26 23:33:23

问题


I have an MVC application that send an e-mail periodically using Quartz.NET. Although the published application works properly on IIS, it cannot works after recycling application pool or restarting the application on IIS. Searching on the web I found several post suggesting to make some changes on config files or IIS, but none of them working properly. So, is there any method to solve the problem? I need a solution that can be applied on application side (or on IIS side if it is simple just making a config changes, etc.). I think this is a common problem when keeping an application on IIS, isn't it?
Note: I use Windows Server 2008 and IIS 7.5.


回答1:


You do not mention in your question where your application is going to run so I guess it's going to be hosted in-house.

Following your comment I gather you do not have any problems installing and running a Windows Service on your server.

My suggestion - and something I've implemented in the past - is to use the ASP.NET MVC application only as a UI where you create, delete or suspend your jobs/triggers which will be persisted in a database so, whatever happens to your application, you won't lose your jobs/triggers and they will be executed as soon as the application goes back on-line.

The database will be shared with the other layer, the Windows Service, which will be responsible for running your scheduled jobs.

First step is to setup and use AdoJobStore to store Quartz.Net data. As you can see in the post there are a few providers you can use.

Second step is to create and configure your Windows Service. I would use TopShelf to host it. The implementation is very simple and straightforward; plus you can use the Quartz.Net integration provided here.

If you go through the documentation you won't find any problem integrating the solution.

Quartz.Net depends on some configuration you have to add in your app.config/web.config. In this answer there's a detail explanation about the configuration and AdoJobStore.

There are a few things to remember implementing this type of solution.
Your Web Application is going to set the property threadPool to ZeroSizeThreadPool in your config:

<add key="quartz.threadPool.type" value="Quartz.Simpl.ZeroSizeThreadPool, Quartz" />

or in your code:

properties["quartz.threadPool.type"] = "Quartz.Simpl.ZeroSizeThreadPool, Quartz";

and it's never going to start the Scheduler (your windows service is going to use that).



来源:https://stackoverflow.com/questions/33593602/cannot-keep-alive-web-application-on-iis-after-recycling-or-restarting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!