Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time Based Events in ASP.net

I need to perform some events (sending emails, etc.) based on time. What is the best way to accomplish this in ASP.net in a hosted (medium trust) environment?

ex: Send email every day at 4:00pm.
ex: Send email after 15min of login.
ex: Send email after 10 hrs of last change to status.

The triggering logic can be complex on some of the requirements, so I need to build a flexible system to handle these sorts of events. I am stuck on the core activation method for this code.

Here are the options I have so far...

1) Timer in Global.asax
+ Simple
- Is not reliable, the web application can unload in IIS and the event will not fire.
? Possibly use external pinger service to keep app alive (reliable?)

2) Windows Service to perform action
- Slip/Maintain separate code.
- Can not install in hosted environment (shared/cloud hosting)

3) Windows Service to call Web App (calls webservice or runs page)
+ All code in web app
- Can not install in hosted environment.

4) SQL Server Job to call a Webservice (via CLR)
? Haven't looked at this.. possible? reliable in hosted environment?

5) SQL Service Broker Timer to add message to call WebService (via CLR)
? Haven't looked at this.. possible? reliable in hosted environment?

6) Windows Workflow?
? No Idea.. does this technology have anything for this?

This seems like a common enough problem, are there third party tools to handle this?

like image 781
Samg Avatar asked Jun 03 '09 16:06

Samg


1 Answers

I have had the same problem, and I agree totally with your analysis. My best solution to date is having an external scheduling application in a computer I control; that application requests the web page that actually does the things.

Ugly but it works, and I have searched for other solutions, believe me!!

like image 108
tekBlues Avatar answered Oct 20 '22 11:10

tekBlues