How to call an async method to create a file on application start up

268 Views Asked by At

I want to create an Asp MVC application to run a code every 12 hours. This code will create a file on the server each time.

So I've made an async method and called it from Application_Start event to make a schedule and It worked fine.

My problem is where I want to create the file. As I call my method from Application_Start, the instance of Server.MapPath is not available there. So I moved my calling code into Application_AuthenticateRequest. But the problem was still here, this time because of my async method that doesn't allow using the Server.MapPath.

What is the solution to do all of these in MVC.net:

  1. Create a method which is called every 12 hours
  2. Create async method to avoid locking application on application_start
  3. Create a file on each call
0

There are 0 best solutions below