Re: Checking if a website is online from a windows app

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Aug 2, 4:17 pm, Peter Duniho <NpOeStPe...@xxxxxxxxxxxxxxxx> wrote:
Markus...@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

Hi Pete, I'll give it a whirl and see how I go. Thanks again for your
help

Regards
Markus

.



Relevant Pages

  • Re: Checking if a website is online from a windows app
    ... I would agree that simply checking the length of the response isn't an appropriate solution. ... 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Model-View-Presenter (MVP) question
    ... Thanks for your response. ... I still have the problem of handling ... What if an Exception is thrown ...
    (comp.object)
  • timeout
    ... I use in the loop code which creates WebRequest, ... response. ... After it is thrown ... exception with message "System.Net.WebException: The operation has ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: HttpWebRequest.GetRequestStream times out
    ... When I encounter this exception, this is printed in the log: ... Stream sendStream = httpReq.GetRequestStream; ... you never read more than 1 kB of the response, ... The request timeout is set to 100 seconds, and the requests that time out ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Validating file names
    ... running Novel, from your G: running Linux file system, from your H: running ... I am not saying one does not exist! ... file file and handle any exceptions that were thrown. ... If an exception is thrown then the specified ...
    (microsoft.public.dotnet.languages.vb)