问题
I have an ASP.NET MVC 3 web app hosted on normal hosting, (i.e., no owned or virtual server), and I would like to be able to store e-mails say in a database and have them picked up and sent in a background job of sorts.
If this was my own server I'd write a Windows Service to handle this, but is there any way I could implement/simulate a scheduled task/background job in a web application process?
回答1:
You may take a look at Quartz.NET. There is a blog post about how you could make it running in medium trust.
回答2:
You can take a look at this post (http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/) which explains on how run scheduled tasks without using windows service, in asp.net or asp.net mvc.
回答3:
You can also use job cash:
HttpContext.Current.Cache.Add("jobkey",
"jobvalue", null,
DateTime.MaxValue,
TimeSpan.FromSeconds(15), // set the time interval
CacheItemPriority.Default, JobCacheRemoved);
For Details See this
来源:https://stackoverflow.com/questions/5159761/send-emails-in-background-job-scheduled-task-in-asp-net-mvc-3