I have method in MVC like
public void Sendmails()
{
//sending mails for every 24 hours.
}
Can I schedule above method to execute fo
I agree with @David, running background tasks in web application is inherently not reliable, but there are scenarios, where this makes sense. I'd recommend reading this excellent article first, http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx/
With .NET 4.5.2, you can leverage HostingEnvironment, as nicely explains this article: http://blog.mariusschulz.com/2014/05/07/scheduling-background-jobs-from-an-asp-net-application-in-net-4-5-2 Quoting from that, "The HostingEnvironment.QueueBackgroundWorkItem method lets you schedule small background work items. ASP.NET tracks these items and prevents IIS from abruptly terminating the worker process until all background work items have completed."
But again, it's not a good practice and if used, it should be used quite wisely.