Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

How to check if web page or image exists without downloading in ASP.NET

I need to check lots of URL's to see if the page or image that the URL points
to actually exists without downloading the actual page/file as this would be
very slow and consume lots of bandwith.

Is there a way to initiate a transfer of the page/image in chunks so that
I can check for a 404 error header so the entire page doesnt have to
be downloaded?

  • 2
  • 2
1 Solution
I could see this example

You can have something like this webservice.
Try to load the result into some simple xml document.
Look if "404 error" message is with inside that xml.

There might be whole lot of messages too like "host not found" etc.

Pretty much tuff. But give a short   :)

angelo_aAuthor Commented:
That's but that's just a wrapper for doing a regular GET or POST request.
This would require downloading the entire image/page to get a response.

I'm looking for a way to request the image/page at a lower level so that
I can stop the transfer once enough info has been recieved to determine
if a valid image/page was returned or a 404 page was returned. This way
only the bare minimum data is transfered. The lists of URL's I need to check
can be from 2000-10000 URL's
angelo_aAuthor Commented:
I found what I needed to do this. In case anyone is interested, you set the
HttpWebRequest object's Method attribute to "HEAD" which returns only
the headers for the requested resource.

You then check the header via the HttpWebResponse.Headers collection.
With this you can check for a 404 and even see what type of resource it is.
Oh that is cool.

PAQed with points refunded (500)

Community Support Moderator

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now