简体   繁体   中英

Task Schedule ASP.NET MVC application

I have a classified web application developed with ASP.NET MVC and I need to implement a advert bump up option.

As a example if someone use this option (for 3 days) today at 10.15 AM, advert should bump up each day 10.15 AM for 3 days.

So I need a scheduler to execute some code to bring up the advert to top of the list.

Can someone explain me how approach this inside my ASP.NET MVC application or using any other 3rd party resource?

save on the database every time the user click on the option. and every time he clicks on the option check if he has click in the pass two days.

You will need to use a task scheduler service. It is not possible to create a scheduled task in ASP.NET MVC, because it simply listens and responds to HTTP requests. You could put your code to bump up the advert in an ASP.NET MVC controller, but you would still need something to send an HTTP request to trigger the controller at the given time. So there's probably not a great reason to put that code in a controller under most circumstances.

It is easy to set up scheduled tasks in most cloud computing environments. For example, in AWS you could write a Lambda function in C# and schedule it with a CloudWatch Events rule.

If your application is running on a Windows Server, the most robust way to implement a task scheduler would probably be to write a Windows Service application to call the task logic on a polling loop. It is also possible to create a console application and trigger it with the Windows Task Scheduler. This approach is quicker and easier to get up and running than developing a Windows service, but in my experience is more likely to fail and quit running without your knowledge. Either way, it will be important to make sure to write good logging and error notification code.

I'm sure there are also good 3rd party tasks schedulers out there too, I just haven't used any of them. Those are just some general guidelines, but if you want more detail on them just let me know and I can post some links.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM