Search code examples
.nethttpwebclienthead

HEAD with WebClient?


I am going to assume the answer is no but.... Is there a way to use WebClient to send the HEAD method and return the headers as a string or something similar?


Solution

  • You are right WebClient does not support this. You can use HttpWebRequest and set the method to HEAD if you want this functionality:

    System.Net.WebRequest request = System.Net.WebRequest.Create(uri);
    request.Method = "HEAD";
    request.GetResponse();