How to execute asp.NET code in scheduled task of windows?
问题:
回答1:
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
回答2:
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
回答3:
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.
回答4:
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.
回答5:
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