467,077 Members | 959 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

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

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
Nov 18 '05 #1
  • viewed: 1554
Share:
1 Reply
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,

--
Scott
http://www.OdeToCode.com

On Wed, 21 Jul 2004 20:17:41 -0500, " Bob" <bo*******@yahoo.com>
wrote:
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


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by support | last post: by
7 posts views Thread by Jonathan Wood | last post: by
4 posts views Thread by Jeremy | last post: by
4 posts views Thread by Brian Kitt | last post: by
2 posts views Thread by Lan W via DBMonster.com | last post: by
1 post views Thread by aalves | last post: by
1 post views Thread by Justin Voelker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.