Until recently, I had heard of the HTTP HEAD method but never actually used it, or quite understood it's usages. I'm sure most of us have used some of the common HTTP Verbs before such as GET or POST. Let me explain a little bit about the HTTP HEAD request method. According to Wikipedia it does the following:
"Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content."
How is this useful to us? Well, let's say for example we needed to check if a resource was available or online but we didn't want to download it. We could simply use the HEAD request to check if it was there - it doesn't download any response and this saves us bandwidth. We can also get the Content Length and the Last Modified date which we can use to further decide whether or not to download the resource. Let's take a look at how to do this in .NET - I have created a simple method that checks if the resource exists.
It's that simple! If we get a response without exception this means that we are able to access the resource. You may want to do some further exception checking, but what you do with it after that is up to you!
For some further reading, please take a look at: