Simulate Windows Service using ASP.NET

How to run scheduled jobs from ASP.NET without requiring a Windows Service to be installed on the server? Very often we need to run some maintenance tasks or scheduled tasks like sending reminder emails to users from our websites. This can only be achieved using a windows service. ASP.NET being stateless provides no support to run some code continuously or to run code at scheduled time. As a result, we have to make our own Windows Services in order to run scheduled jobs or cron jobs. But in a shared hosted environment, we do not always have the luxury to deploy our own windows service to our hosting provider’s web server. We either have to buy a dedicated server which is very costly, or sacrifice such features in our web solution. However, running scheduled task is a very handy feature especially for sending reminder emails to users, maintenance reports to administrator, run cleanup operations etc. So, I will show you a tricky way to run scheduled jobs using pure ASP.NET without requiring any windows service. This solution runs on any hosting service providing just ASP.NET hosting:

http://www.codeproject.com/useritems/ASPNETService.asp

If you find this article useful, please vote for me.

Published Tuesday, November 01, 2005 6:17 PM by omar
Filed under:

Comments

# re: Simulate Windows Service using ASP.NET

Sunday, December 18, 2005 11:11 PM by Rashid Ashraf Malik
Though i m currently working as QA in my company,but i communicated this code to my developers and it was of great help.
Keep up good work.

# re: Simulate Windows Service using ASP.NET

Monday, August 07, 2006 1:08 AM by Amit Joshi
Hi,
I am Amit Joshi a c#, asp.net  developer.
My problem is to create a setup project which will add one scheduled task (windows). That is an exe currenlty its work is to run one stored procedure
, get some data and send mails according through c# code. I want user to give chane to select time to run this utility say at midnight 12:00 A.M.
How to achieve this? If you could send me code in C# I will be highly obliged.
Amit Joshi
Pune. India.

# re: Simulate Windows Service using ASP.NET

Wednesday, May 30, 2007 8:07 AM by mangesh nerkar

i have gone through numerous site,blogs and community but all in dust. If any has this stuff.........it would be great.

# re: Simulate Windows Service using ASP.NET

Thursday, July 05, 2007 2:39 AM by Rohit

good and useful article.

# re: Simulate Windows Service using ASP.NET

Tuesday, August 21, 2007 5:46 AM by krishnangshu banerjee

It is running only for two times....and time gap is 1 min 20 sec

# re: Simulate Windows Service using ASP.NET

Tuesday, June 03, 2008 2:35 AM by K.G.

Hey.

I have been writing a component (AspTaskManager) base on this idea, but I've run into something weird.

Even with the webclient keeping the application alive, the application will end after 1,5 days anyway... then the application immediately restarts again.

I presume that this is worker process recycling or something ?

Anyway, I was wondering if you experienced this, and if you might have a solution for it ?

You can contact me at "valheruasu at hotmail dot com".

Thank you.

K.

# re: Simulate Windows Service using ASP.NET

Sunday, November 16, 2008 1:35 PM by Steve Wellens

FYI: The link provided doesn't work.

www.codeproject.com/.../ASPNETService.asp

Leave a Comment

(required) 
(required) 
(optional)
(required)