By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,590 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,590 IT Pros & Developers. It's quick & easy.

Determine if a page is up or down.

P: n/a
We have a site, for reference I'll call this MainSite,
that has certain pages actually hosted on another site,
I'll call this ChildSite. In MainSite when you click on a
certain link, it loads a page with an IFrame that points
to a page in ChildSite. MainSite and ChildSite are on two
different machines. If MainSite can "see" ChildSite,
everything works like a champ. However, if there is a
network problem, firewall issue, or something else wrong
with "seeing" the ChildSite, the users in MainSite get
an "Action Cancelled" error. It's totally confusing to
receive that error and we're trying to come up with a way
around it.

What I want to do is check the availability of that page
in ChildSite before the IFrame starts its request. I have
some code that works fine under good conditions, here's
the basic concept:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create
(url);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Console.WriteLine(response.StatusCode);

....basically i want to check and see if the response
status is OK(aka 200). My concern is this, usually if
there is a connectivity problem, the page will sit there
for up to 15 seconds before it displays a message
indicating the problem. If the page is up, it will
display in maybe one second, it's a very lite page with
very little to display or process. I need to know if I
should load up a worker thread to test for the web page
status, and then in a watcher thread, determine if after
say 2 seconds, if i haven't received an OK status, that
it's safe to say the page is down so kill the worker
thread. Or, can I rely on the HttpWebRequest to return a
status quickly enough to determine page status?

Or does anyone have a different but reliable solution for
checking the status of a web page?
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
you approach will work for most cases, but only if connectivity is down
between your site and the child site. it may be down for the user to child,
but ok for your site. you don't need a seperate thread, unless you just want
to poll and set a status, just reduce the timeout. polling would lead to
false ok's just when the site goes down.

another common approach is for your main site could proxy the child site.
your site translates the url to a local site and fetches the pages. you can
do this with a filter.

-- bruce (sqlwork.com)
"Chris Carter" <ch***@panteravb.com> wrote in message
news:09****************************@phx.gbl...
We have a site, for reference I'll call this MainSite,
that has certain pages actually hosted on another site,
I'll call this ChildSite. In MainSite when you click on a
certain link, it loads a page with an IFrame that points
to a page in ChildSite. MainSite and ChildSite are on two
different machines. If MainSite can "see" ChildSite,
everything works like a champ. However, if there is a
network problem, firewall issue, or something else wrong
with "seeing" the ChildSite, the users in MainSite get
an "Action Cancelled" error. It's totally confusing to
receive that error and we're trying to come up with a way
around it.

What I want to do is check the availability of that page
in ChildSite before the IFrame starts its request. I have
some code that works fine under good conditions, here's
the basic concept:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create
(url);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Console.WriteLine(response.StatusCode);

...basically i want to check and see if the response
status is OK(aka 200). My concern is this, usually if
there is a connectivity problem, the page will sit there
for up to 15 seconds before it displays a message
indicating the problem. If the page is up, it will
display in maybe one second, it's a very lite page with
very little to display or process. I need to know if I
should load up a worker thread to test for the web page
status, and then in a watcher thread, determine if after
say 2 seconds, if i haven't received an OK status, that
it's safe to say the page is down so kill the worker
thread. Or, can I rely on the HttpWebRequest to return a
status quickly enough to determine page status?

Or does anyone have a different but reliable solution for
checking the status of a web page?

Nov 18 '05 #2

P: n/a
Thanks for the response Bruce, I'll look into the proxy
suggestion. I like the idea of just testing whether the
main site can see the child site by getting back an OK
status. It's really just to shorten the timeout like you
mentioned and possibly give us a chance to throw up a
slightly friendlier "home grown" error page that makes it
_look_ like we have everything covered. Thanks again.
-chris

-----Original Message-----
you approach will work for most cases, but only if connectivity is downbetween your site and the child site. it may be down for the user to child,but ok for your site. you don't need a seperate thread, unless you just wantto poll and set a status, just reduce the timeout. polling would lead tofalse ok's just when the site goes down.

another common approach is for your main site could proxy the child site.your site translates the url to a local site and fetches the pages. you cando this with a filter.

-- bruce (sqlwork.com)
"Chris Carter" <ch***@panteravb.com> wrote in message
news:09****************************@phx.gbl...
We have a site, for reference I'll call this MainSite,
that has certain pages actually hosted on another site,
I'll call this ChildSite. In MainSite when you click on a certain link, it loads a page with an IFrame that points
to a page in ChildSite. MainSite and ChildSite are on two different machines. If MainSite can "see" ChildSite,
everything works like a champ. However, if there is a
network problem, firewall issue, or something else wrong
with "seeing" the ChildSite, the users in MainSite get
an "Action Cancelled" error. It's totally confusing to
receive that error and we're trying to come up with a way around it.

What I want to do is check the availability of that page
in ChildSite before the IFrame starts its request. I have some code that works fine under good conditions, here's
the basic concept:

HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Console.WriteLine(response.StatusCode);

...basically i want to check and see if the response
status is OK(aka 200). My concern is this, usually if
there is a connectivity problem, the page will sit there
for up to 15 seconds before it displays a message
indicating the problem. If the page is up, it will
display in maybe one second, it's a very lite page with
very little to display or process. I need to know if I
should load up a worker thread to test for the web page
status, and then in a watcher thread, determine if after
say 2 seconds, if i haven't received an OK status, that
it's safe to say the page is down so kill the worker
thread. Or, can I rely on the HttpWebRequest to return a status quickly enough to determine page status?

Or does anyone have a different but reliable solution for checking the status of a web page?

.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.