VB.NET Use WebRequest to check if URI is valid

Posted by Robbo on Stack Overflow See other posts from Stack Overflow or by Robbo
Published on 2010-05-27T23:17:37Z Indexed on 2010/05/27 23:21 UTC
Read the original article Hit count: 179

Filed under:
|

Looking for the best way to determine if a URI exists in VB.NET without downloading the actual content. System.IO.FileExists/My.Computer.FileSystem.FileExists can be used locally to determine if a file exists, is there an equivalent for the Web?

Currently I am using a HttpWebRequest to check URI existance using the ResponseStream. This populates the stream if the target does exist and throws an exception if it doesn't. The function is being expanded to also check for PDF files (typically 5MB +), images, etc and it will be a waste of time/bandwidth to actually populate the content into a stream.

In the case of "Success" (the target does exist) I do not wish to download the file or page, simply to end up with a Boolean which indicates the whether something exists at the end of this URI.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about httpwebresponse