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:

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

8 thoughts on “Simulate Windows Service using ASP.NET”

  1. 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.

  2. Hi,

    I am Amit Joshi a c#, 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.

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

  4. 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.


Leave a Reply