Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I have a question for task scheduler.
I have a button in aspx page and this button does the below when aspx page is Page_Load
-	Connect web service
-	Get json data from web service
-	Update my table on Sql Server

Wondering what the next step is in order to run automatically everyday 9:00am
Do I have to create exe file? Or .bat file or .dll ?
Or task scheduler can run aspx page?

Any help would be greatly appreciated. Thank you in advance for your help.


What I have tried:

Googled the best solution but still no clue.
Posted
Updated 9-Feb-16 5:11am
v2
Comments
F-ES Sitecore 9-Feb-16 11:01am    
google "asp.net scheduled task", this is a very frequently asked question.

ASP.Net is the wrong platform to use when scheduling tasks because of the way the web works. The code is not running until someone visits the page, then the server runs the code for the page, sends the html back to the client and then disconnects and waits indefinitely for someone else to request a page.

You could certainly take the code and put it into an exe and then schedule that. However, since you already have the code in a webpage your fastest way to schedule this is to probably create a batch file that loads the webpage on the server and then schedule that.

See windows - How can I open a URL on a schedule in the default browser? - Super User[^] for examples on how to run a webpage. Essentially you put start or explorer and then the url. Pretty simple.
 
Share this answer
 
Me, I set a scheduled event on my hosting service which runs a specific application for me at a specific interval.
For Arvixe, there is a description here: How to Use Schedule Task in DotNetPanel to Execute a URL | Arvixe Blog[^] but it will probably be different for your hosting service.
 
Share this answer
 
You may try to take a look at the tutorial for creating a WinService at:
Walkthrough: Creating a Windows Service Application in the Component Designer[^]

For you situation, I think you have to copy the code inside the Button_Click EventHandler into the EntryPoint of the WinService, which is named "MyNewService()" in the article.

Hope it'll help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900