1

I want to use windows task scheduler to call a .aspx web page to run my code in certain amount of time ,my question is : 1- how I can do this in windows server 2003 or 2008 ? 2- is there any other way to do this, or the windows scheduler is the best option?

Thanks for helping me.

Simon
  • 71
  • 1
  • 1
  • 6

2 Answers2

1

If you have an established ASPX page then your approach would be the fastest to implement. Just create a console EXE application that using WebClient class would make a request to your page. And set a Windows scheduled task to call that EXE.

As an alternative - if you can refactor your code, you can use Quartz.NET scheduler to call only specific portions of the code without resorting to a Web call.

Yuriy Galanter
  • 38,833
  • 15
  • 69
  • 136
  • from windows scheduler ,is there any way to hit a web page directly or as you mentioned ,I need to create console apps first ? and for second option ,I didn't understand what did you mean about "refactor your code" ?is it possible to explain me ,thanks – Simon Nov 29 '13 at 17:10
  • Scheduler is just that - a scheduler. It just starts something. And that something has to call your page – Yuriy Galanter Nov 29 '13 at 17:15
-2

I have similar problem some years ago. My solution is to create second site "Y" which is online and in every interval, request your main site aspx page.

As I know there is some free website that does this task.

Edit: You can use webclient to refresh( or view) main site from second site as demonstrate here: How can I download HTML source in C#. For interval, you can use asp.net Timer control.

One of online sites that do job of "second job" is http://www.onlinecrontab.com/. For finding similar sites search for 'cron' as demonstrated here: Requesting website regularly within specific interval

Community
  • 1
  • 1
Seyed Morteza Mousavi
  • 6,855
  • 8
  • 43
  • 69
  • how you set interval in your second website ,what was your solution ? – Simon Nov 29 '13 at 17:00
  • 1
    So, just to confirm, for the scheduler on the second site to work, someone always have to have a webpage from that site open in his browser? If no one goes to the second site - scheduler will not work and the first site will never be called? – Yuriy Galanter Nov 29 '13 at 21:07
  • if you have access to server, you can open page ultimately, but if you do not have access, the best way is to sign up in sites that will request your main website page for special interval. currently I don't know such website, but if I found that I will came back here – Seyed Morteza Mousavi Nov 29 '13 at 23:09
  • Your solution requires regular human interaction with the second site. Said human may just as well open page from the first site manually. It is not a real scheduled job. – Yuriy Galanter Nov 30 '13 at 02:10
  • @YuriyGalanter i added some information in edit that describe my solution. – Seyed Morteza Mousavi Nov 30 '13 at 15:00
  • Really, CRON? How would a cron job retrieve data from external page to update OP's database with the results? – Yuriy Galanter Nov 30 '13 at 15:53
  • I mean with cron job, we can refresh main site web page that runs robot. It's main site job that fetch information periodically or what ever it is. – Seyed Morteza Mousavi Nov 30 '13 at 15:58