C
Chris Carter
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?
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?