Scheduled tasks for ASP.NET

2019-06-11 09:56发布

How to execute asp.NET code in scheduled task of windows?

5条回答
我只想做你的唯一
2楼-- · 2019-06-11 10:14

ASP.Net has good integration with Windows Workflow (WF). I've accomplished 2 project with such integration. WF allows persists tasks, so it is independent on IIS restarting or system crash

查看更多
Summer. ? 凉城
3楼-- · 2019-06-11 10:14

If you have full access to the server, use the scheduled tasks.

If you do not have access (shared hosting), create a webpage/service that you can call to trigger the action. Be aware that the "action" is limited in time.

You could create a small application, that you can schedule on you own computer to call the remote server, to trigger the action.

查看更多
ら.Afraid
4楼-- · 2019-06-11 10:17

There is no way to schedule ASP.NET code from within a web application, because the web is stateless.

My preferred method to schedule .NET code, is to write a windows service that I install on the web server. See. http://blog.dogma.co.uk/search/label/windowsservice.

An quicker, less efficient, way is to add the code to a page and execute that page from Windows Scheduled Tasks.

Rich

查看更多
疯言疯语
5楼-- · 2019-06-11 10:22

I've often used wget / curl to do exactly this from windows scheduled tasks (or even from cron on a different server). For certain things it is better to keep it all within the web application.

e.g.

   curl -k  https://example.com/update.aspx?id=71077345 -u username:password

or

   wget -O - http://example.com/process.php 
查看更多
老娘就宠你
6楼-- · 2019-06-11 10:29

The simplest and probably the easiest way to do this is to make the code a command line app and then execute it using the Windows Scheduler found in Control Panel.

查看更多
登录 后发表回答