ASP.NET site - running code at a specific time

I plan to create an ASP.NET website that will be hosted on a shared host. For this, I do not have the option for a Windows service. What are my parameters specific to a website where I can complete a task, say, at 3 a.m. Maybe start a separate thread or something like that?

Thanks.

+4
source share
3 answers
+2
source

I was just about to do something like this.

What should happen is a separate thread that needs to be released from Global.asax.

void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } 

You will also need to consider that the application pool will be repeatedly processed, so make sure that it is based on a specific time, and that you also have a database in which the 3am application pool is stored, running or not running, which is very likely.

You will also need to have some form of maintaining the service, as if your site is inactive, the application pool will not be restarted until someone hits it.

+4
source

We process this type of activity in one of two ways:

1) Delete the thread in global.asax Application_Start , which is responsible for performing actions at the appropriate time.

2) Store the dummy object in HttpRuntime.Cache with the specified timeout when the application starts and follow the steps in the CacheItemRemovedCallback .

+4
source

Source: https://habr.com/ru/post/1387310/


All Articles