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

后端 未结 2 869
暗喜
暗喜 2021-01-22 22:42

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 int

相关标签:
2条回答
  • 2021-01-22 23:13

    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

    0 讨论(0)
  • 2021-01-22 23:23

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

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

    0 讨论(0)
提交回复
热议问题