简体   繁体   English

自动运行ASP.net c#Web应用程序

[英]Run ASP.net c# Web Application Automatically

I have a ASP.net web application that checks the status of my servers, it then wraps all this information up and puts it in a email. 我有一个ASP.net Web应用程序,它检查我的服务器的状态,然后将所有这些信息包装起来并将其放入电子邮件中。 My Question how do I run this automatically say every day at like 2:00am, or like every 12 Hours? 我的问题如何自动运行这样说每天凌晨2点,或者每12个小时?

Thanks 谢谢

最好的解决方案是创建一个简单的MS Windows服务来完成这项工作。

You'd better implement this as a separate process from your ASP.NET application. 您最好将其作为与ASP.NET应用程序分开的进程实现。 Phil Haack has summarized the reasons in this blog post . Phil Haack在这篇博客文章中总结了原因。 A Windows service for example or even a console application using the windows scheduler could work just fine for this task. 例如,Windows服务甚至使用Windows调度程序的控制台应用程序都可以正常工作。

You want a scheduler - I recommend Quartz.NET . 你想要一个调度程序 - 我推荐Quartz.NET

As others have said, your code doesn't have to be in a web app. 正如其他人所说,您的代码不必在Web应用程序中。

If it is, then schedule a job that uses WebClient to make a request to your web app. 如果是,则安排使用WebClient向您的Web应用程序发出请求的作业。

Check out WebDriver . 查看WebDriver

It's intended as a test / qa framework, but there's nothing stopping you from using it in a console application, which you can then run as a Scheduled Task. 它旨在作为test / qa框架,但没有什么能阻止您在控制台应用程序中使用它,然后您可以将其作为计划任务运行。 Note that whatever machine runs the Scheduled Task has to have a browser that WebDriver can fire up. 请注意,无论运行什么机器,计划任务都必须具有WebDriver可以启动的浏览器。

The easiest solution would be to create a scheduled task on your server using the Windows Task Scheduler and setup this job so that it uses internet explorer to visit your webpage. 最简单的解决方案是使用Windows任务计划程序在服务器上创建计划任务并设置此作业,以便它使用Internet Explorer访问您的网页。

If you open the task scheduler and create a new task. 如果打开任务计划程序并创建新任务。 In the "Run" field put: 在“运行”字段中输入:

"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE""http://www.yoursite.com/yourpage.aspx" “C:\\ Program Files \\ Internet Explorer \\ IEXPLORE.EXE”“http://www.yoursite.com/yourpage.aspx”

Then in the "Start in" field put: 然后在“开始”字段中输入:

"C:\\Program Files\\Internet Explorer" “C:\\ Program Files \\ Internet Explorer”

Now configure this task to run at 2:00am every day. 现在将此任务配置为每天凌晨2:00运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM