1

We want to check if a site exists/is available by using the following piece of code:

var request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "HEAD";

As we don't want to download the whole site I thought it might be enough to just get the headers and evaluate them.

Am I missing there some thoughts or is it really enough to check if the website is up and reachable?

Oguz Ozgul
  • 6,809
  • 1
  • 14
  • 26
Ivan Sieder
  • 934
  • 1
  • 10
  • 24
  • 1
    See http://stackoverflow.com/questions/7523741/how-do-you-check-if-a-website-is-online-in-c – Munir Nov 27 '15 at 14:20

1 Answers1

4

Yes, HEAD is probably the best option.

As mentioned in RFC 2616 :

This method is often used for testing hypertext links for validity, accessibility, and recent modification.

Eric Citaire
  • 4,355
  • 1
  • 29
  • 49