在 IIS 中启动的 ASP.NET 网站服务上运行作业
我有一些在 Application_Start 上调用的方法。它从任何用户的首页请求开始。
但我有另一个应用程序,依赖于在 Application_Start 期间触发的任务。
因此,如果 IIS/网站重新启动,则另一个应用程序无法从网站获取某些数据,直到有人请求正在运行的网站上的页面。
有没有办法在网站启动时运行某些任务;没有用户端的任何交互,只是在 IIS 中启动网站并完成我想要的工作?
PS有关实现架构的更多详细信息:
网站启动消息服务的实例并开始通过该服务(位于另一台服务器上)发送消息。我知道最好为这类事情创建 wcf 或 windows 服务,但是在我加入这个项目之前就有人写了这个网站。因此客户端(从消息传递服务器接收消息)对网站一无所知。这里的网站只是管理面板,用于打开/关闭一些消息传递功能。
我的解决方案
为我的任务创建了 Windows 服务。运行良好,在本地系统帐户下写入 Windows 事件日志没有问题。
I have some method that is invoked on Application_Start. And it starts on first page request by any user.
But i have another application, dependent on that task that fires during Application_Start.
So that if IIS/website is restarted- another application cant get some data from website, until someone requests page on the running website.
Is there a way to run some task on website start; without any interaction from user side, just to start website in IIS and do the job i want?
PS more details on implementation architecture:
Website starts an instance of messaging service and starts sending messages through that service(that is located on another server). I know that it would have been better to create wcf or windows service for this kind of things, but someone wrote this website before i was included in this project. So clients(that receive messages from messaging server) do not know anything about website. Here website is just administrative panel to turn on/off some messaging features.
My Solution
Created windows service for my task. Works well, under local system account has no problems with writing to windows event logs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个“在 ASP.NET 中实现重复后台任务的危险"
此外,您还应该考虑安装 Quartz.NET 作为一项服务,以便您可以远程设置计划任务。
Check out this "The Dangers of Implementing Recurring Background Tasks In ASP.NET"
Also you should consider installing Quartz.NET as a service, so that you can setup scheduled tasks remotely.
你可以试试这个。
You can try this.