news.microsoft.com <me@itsme_nospam.com> wrote:
> I want to make a boolean function to determine if a given URL is "alive",
> where 'alive' means it does not result in DNS error, 404 error, or other
> common errors.
>
> I am currently using this code, but I'm not sure if it is the best way to do
> it:
<snip>
I don't know of any way of doing this without incurring an exception
other than implementing HTTP yourself.
You're right to be concerned about using exceptions for this kind of
detection, but I wouldn't worry too much about the performance side of
things - the time taken to throw the exception is likely to be
insignificant compared to the time taken to do the DNS lookup etc in
the first place.
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too