DeepSpace101
DeepSpace101

Reputation: 13762

Run a controller method at a fixed schedule within MVC?

We have an existing method in an existing controller that we'd like to call at a specific schedule (eg "daily at 2am"). The application is an MVC3 application running on Azure as a web role and we don't want to create, maintain and pay for an entire new role (worker role) just to run one small piece of identical logic.

Is it possible to schedule a controller method to trigger off at a specific scheduled time in the future? Also, would the same technique work in regular ASP.NET webforms?

Upvotes: 3

Views: 2240

Answers (3)

John Mc
John Mc

Reputation: 2933

I've successfully used Cron jobs in a Shared hosting environment where scheduled tasks/powershell wasn't available.

Here's a website explaining more about it

Upvotes: 0

barry
barry

Reputation: 835

You could use Phil Haack's WebBackgrounder as described here.

Upvotes: 1

Bart Czernicki
Bart Czernicki

Reputation: 3693

Assuming you can just call this controller action with a URL, you can just... 1) create a PowerShell script to "ping" the website: http://learn-powershell.net/2011/02/11/using-powershell-to-query-web-site-information/ 2) Schedule that PowerShell script via remote desktop in a Scheduled Task that runs at 2am

You could also write a deployment script that automates #2.

Upvotes: 2

Related Questions