I have method in MVC like
public void Sendmails()
{
//sending mails for every 24 hours.
}
Can I schedule above method to execute fo
Like everyone said that it is not a good practice to do long running background processes in your .net web application for reliability etc.
You can create an external trigger that calls into your MVC action method every 24 hours. So you are executing your code every 24 hours. There are multiple ways and services to do that, i have used different services. Or you can create your own if you do not want to use third party.
For example, you can use pingdom.com free account to call a certain url every period. So in pingdom you can enter the url to your MVC action.
http://domain/controller/action
And that will be called every 24 hours and your code will run on schedule.
Update: recently i have been using Azure scheduler, which is build for scenarios like this. https://azure.microsoft.com/en-us/services/scheduler/