Humayoo
Humayoo

Reputation: 690

ASP.NET MVC3 how to excute action method of controller using timer with interval of one hour

Hello

i am using asp.net mvc3. i have one special controller which have one special action method. i need to execute this action method using timer with the interval of an hour.

any best and efficient idea.

thanks

Upvotes: 2

Views: 3018

Answers (2)

nmit026
nmit026

Reputation: 3364

Azure Functions to the rescue! It was designed for exactly this. You can schedule functions using a timer trigger.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview

Upvotes: -1

Humayoo
Humayoo

Reputation: 690

i am able to solve th problem using VB Script and windows schedule. please follow the following steps.

  1. Make VB Script like below to call your controller action. give some name like schedule.vbs

    Call ScheduleTask() 
    
    Sub ScheduleTask()
    On Error Resume Next
    
    Dim objRequest
    Dim URL
    
    Set objRequest = CreateObject("Microsoft.XMLHTTP")
    URL = "http://localhost/controller/action"
    
    objRequest.open "GET", URL , false
    
    objRequest.Send
    
    Set objRequest = Nothing
    
    End Sub
    
  2. make windows schedule of "schedule.vbs" file as you want. if there is permission problem for execute schedule.vbs file, please give the required permission to it.

thanks

Upvotes: 3

Related Questions