Is it good to use Windows Service to schedule any operation on server side in ASP.Net MVC

Topics: ASP.NET MVC, General
Jan 28, 2014 at 6:49 AM
Hi,

Kindly suggest me that, i want to schedule any operation (eg. mailing daily report)on the server side in ASP.Net MVC. I searched over internet and found that either use Windows Service or console app. I need suggestion regarding whether i use Window service or console app (or any other solution) if i use hosting with shared server.

Thanks
Mar 13, 2014 at 12:36 PM
Edited Mar 13, 2014 at 12:44 PM
Hi,

Web Servers are intended for servicing web requests, not background processing. Thus "on the server side in ASP.Net MVC" is not what you want to do.

Windows Services are for background stuff that needs to be active continually, e.g. you could host some WCF service in a Windows Service. However, writing a reliable(!) Windows Service can become quite complicated, which is why it's probably overkill in your case.

Many demands for background processing fall in the same category as your demand: Do something periodically, but in between just go to sleep. There's already a service that takes care of the "so something periodically" part: The Windows Task Scheduler. In these cases the most simple solution is to write a vanilla command line app that does the work once, and register it with the task scheduler. See http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx .

HIH,
AJ