Approaches to call an asp.net mvc action method on timely basis RRS feed

  • Question

  • User-540818677 posted

    I am planning to create an asp.net mvc web application which will perform a single sync job, to achieve this:-

    1. We have a 3rd party ERP system which will be generating a .csv file on timely basis, where it will generates a .csv file once per hour. The .csv file contain info about our company assets, such as type, price, name ,location, etc…

    2. Now i will develop an asp.net mvc web application which will read the .csv data and update a database with this data.

    So I am planning to do the following :-

      1. I will create a new database, which will contain the data.

      2. I will create a new asp.net mvc-5 web application which have a SYNC action method, which will read the .csv data, and update the database. now the problem I am facing is that I need the sync job to run per hour or on a specific schedule.

    Now from my previous experience I can list these 2 approaches to call an action method on timely basis:-

    1. Inside the asp.net mvc ‘s global.asax I can create a schedule which runs each hour.

    2. I can use third party tools such as Hangfire to schedule the tasks.

    Now using any of these approaches will cause this limitation:-

    1. The global.asax or the third party tools such as Hangfire will run under the application pool, and if no action is performed on the application, then the schedule will never run, since the application pool will not be active. But on my previous applications this was not a real problem as the systems contained many views beside the schedule jobs , so the system stay active almost 100% over working hours.

    But in my current project the web application will not be accessed by users, since it will only do a single sync job, and there is not any other functionalities for end users. so in this case the sync job will never run , since the application pool will not be active. So can anyone advice if these approaches sound valid to fix my problem:-

    1. To create a windows schedule task which will be calling the action method URL per hour:-

    schtasks /create /tn "my scheduled task" /tr "powershell -ExecutionPolicy unrestricted -Command \"(New-Object Net.WebClient).DownloadString(\\http://url .to.be.executed/cron.php\\")\" /sc DAILY /st 07:00:00 /ru System

    1. To create 2 schedule tasks inside the global.asax . one schedule task will call the application url each 5 minutes to keep the application pool alive, and another schedule task which call the sync action method each hour. In this case the application will keep calling itself every 5 minutes which will force the application pool to say alive and the sync job will run each hour even if no users access the system …

    So can anyone advice on this please?


    Thursday, December 17, 2015 5:30 PM


  • User-1103938767 posted

    There is one more alternative to achiceve this goal. You can create SSIS Package that will import data from .csv file to database and you can schedule that package to run periodically.

    I think it will be easier to achieve this task

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 18, 2015 5:34 AM