how to monitor website availability from an ASP.NET app?

B

Bob

I'm trying to centralize some of the resources (images, css, footer etc)
into one website that all my apps can use. Simple things like images and
css would be a direct link (e.g. img
src=http://myresourcecenter.com/images/logo.gif) and some others would be a
web service call with the results to be cached by individual apps. The
problem is, if this resource website is down, all my web apps would cease to
work, so I need to put in a mirror site of it. I'm thinking of setting up
some sort of mechanism in these individual apps that can ping a page on the
resource website, say, every 60 seconds, if it doesn't get a response (e.g.
throws a WebException), it assumes the resource website is down and changes
the value of the global variable that holds the resource website URL to that
of the mirror site. Essentially a simple failover solution. The problem is
I'm not sure what's the best way to do this. I guess this "monitor" has to
be in the same thread as the web app so it can change the value for the
entire app, but the only way to fire the check regularly I can think of is
using Thread.Sleep(). This halts the entire web app though. So I need
something that doesn't interfere with the web app thread, and at the same
time can change a global value in the app. Could anyone comment on what
I'm thinking? whether this is doable, and possibly how?

Thanks a lot in advance.
Bob
 
S

Scott Allen

Hi Bob:

What you are looking for is certainly doable. Check out the Timer
class in the System.Threading namespace. You could start the timer
during the Application_Start event, and at the interval you specify it
will fire a method on a thread from the thread pool. Inside the
callback method check the availability of the web service and adjust
your settings accordingly.

HTH,
 
Joined
Aug 16, 2007
Messages
1
Reaction score
0
Another option you can try the website monitoring service

Hi

Another option you can try the website monitoring service. I have use the service from www.IPCheckpoint.com. It keep your website under monitor, if your website is down, it can send an email and SMS to your mobile phone, You can view how quick your website will be loaded from different country. I think it is better than doing under ASP.net code, save you some time.
 

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

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top