在 IIS 中启动的 ASP.NET 网站服务上运行作业

发布于 2024-12-21 00:41:57 字数 518 浏览 3 评论 0原文

我有一些在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

携君以终年 2024-12-28 00:41:57

看看这个“在 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.

拥有 2024-12-28 00:41:57

你可以试试这个。

  • 将代码中的条目放入事件日志中
  • 使用 Windows 任务计划程序创建任务
  • 创建触发器作为“在事件上开始任务”
  • 使用所需的作业创建操作

You can try this.

  • Put an entry in your code into event log
  • Use the windows task scheduler to create a task
  • Create a trigger as "Begin the task On an event"
  • Create the action with the job you want
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文