Re: Checking if a website is online from a windows app
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Wed, 01 Aug 2007 23:17:46 -0700
MarkusJNZ@xxxxxxxxx wrote:
Hi Pete, a 404 error is fine but I am not sure if a 404 will return a
string length > 0(?) from the webrequest. If so checking the sring
length would fail even though the website was still alive.
Why does it matter? If you get a 404 error, then that itself tells you the information you want to know. Why would you care about any data past the error response, even if it exists?
This post was to ask if I am doing things the right way or if someone
can recommend a better way to do things.
Well, I would agree that simply checking the length of the response isn't an appropriate solution.
For all I know there may have been an obscure method buried deep in
the .NET 2.0 framework which did what I am going to do manually :)
I don't have any first-hand experience with the HttpWebRequest class, but it looks to me as though if any HTTP error occurs when you call GetResponse(), a WebException will be thrown. You can look at the Response property of the WebException to see the details of the error, but in your case the mere fact that the exception is thrown would probably suffice.
Are you finding that you have a situation when the web site is not available and yet an exception is not thrown when you call GetResponse()?
Pete
.
- Follow-Ups:
- Re: Checking if a website is online from a windows app
- From: MarkusJNZ
- Re: Checking if a website is online from a windows app
- References:
- Checking if a website is online from a windows app
- From: MarkusJNZ
- Re: Checking if a website is online from a windows app
- From: Peter Duniho
- Re: Checking if a website is online from a windows app
- From: MarkusJNZ
- Re: Checking if a website is online from a windows app
- From: Peter Duniho
- Re: Checking if a website is online from a windows app
- From: MarkusJNZ
- Checking if a website is online from a windows app
- Prev by Date: Re: System Standby mode.
- Next by Date: Re: TabControl.Controls.Add System.ArgumentException
- Previous by thread: Re: Checking if a website is online from a windows app
- Next by thread: Re: Checking if a website is online from a windows app
- Index(es):
Relevant Pages
|