Have a background process running continously on a

2019-02-07 17:51发布

问题:

I have an ASP.NET MVC4 website running and now i need some sort of background task that is continously running. But is this even possible?

The MVC4 website is a sort of notifying system. Other websites can register a Callback URL on this website and this website should trigger that callback URL for a specified interval. So, for every hour for example.

Normally the code of my website only becomes active when I visit a page. But in order to make this work I need a way to have my ASP.NET website to run in the background continously. So it can do its checks and make an HTTP call when necessary.

It's important though that other websites can register their own Callback url through an http web request, and not through a socket.

Is something like this possible in an ASP.NET MVC web application? Or do I need a different approach?

回答1:

Check this out: Easy Background Tasks in ASP.NET MVC



回答2:

I do not prefer to run continuous jobs in asp.net because of these reasons.

  • You can use Windows Azure Scheduler for scheduling http requests for a particular URL.
  • Alternatively you can create a Windows service (example here)
  • You can also try console app and schedule it using Windows task schedule
  • Azure Worker Role is also a good option