Web application running a service when EXE not allowed

  • Thread starter Thread starter Steven Nagy
  • Start date Start date
S

Steven Nagy

Hi all,

I have a problem where I am developing a site for a client that needs
to perform a certain analysis against the database every hour, on the
hour. The problem is that the hosting company will only allow a
standard ASP.NET web app to be run on their server; no EXE's can be
run. So I am not sure how I would implement functionality to run the
required service.

You see, its theoretically possible that no one would use the site on a
particular day, but during that day there still needs to be something
running to analyse the database every hour.

I guess the problem is that I am thinking of web apps as being "user
driven". Ie, a page only executes because it has been requested by a
browser. I have ideas that might be too crazy to even attempt. For
example, creating a timer and putting it in some sort of application
state (I assume something like this exists) and the timer tick event
does my processing. I could then write an admin page that could check
the status of the timer, if its started or not, thus being able to turn
my "service" on and off. I could create the timer on application_start
in Global.asa and put the object somewhere I can retrieve later from an
admin login.

Is my idea crazy? Whats the best way to approach this specific problem?


Many thanks,
Steven
 
You could quite easily handle this by creating a background thread in the
application (but it would also need to be smart enough to only run a single
instance even if there are many worker processes, assuming you are running
on a single machine a mutex could easily handle this case).

Cheers,

Greg Young
 
You might run into some problems with running a timer from ASP.NET. For
one I think the application is unloaded from memory if it doesn't get
any requests for a while. Also, the hosting provider may restart IIS
occasionally. I know some places that restart IIS every night and I
think by default it restarts itself every 27 hours or so.

Is the database MS SQL Server? If so it has some tools to schedule
tasks. Though I don't know if the host would give you access to these.

Another thought is have a scheduled task/cron job on another connection
hit a maintenance.aspx page every hour. Or even use a web service.
 
Yeah I had considered using a web service, and then running the job on
a different server, but its only a small site for a small client and
its only the one host, shared server.
I could host it at my home, but I'm not looking for an ongoing support
contract, plus the legal issues if it goes down, etc.

So I will try the seperate thread suggestion. Otherwise I'll tell the
company to consider another host.

Cheers guys.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top