HEAD with WebClient?

user34537 picture user34537 · Jul 16, 2010 · Viewed 9.3k times · Source

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?

Answer

btlog picture btlog · Jul 16, 2010

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();