HTTP HEAD request with HttpClient in .NET 4.5 and C#

The Wavelength picture The Wavelength · May 7, 2013 · Viewed 24.3k times · Source

Is it possible to create a HTTP HEAD request with the new HttpClient in .NET 4.5? The only methods I can find are GetAsync, DeleteAsync, PutAsync and PostAsync. I know that the HttpWebRequest-class is able to do that, but I want to use the modern HttpClient.

Answer

Smigs picture Smigs · May 7, 2013

Use the SendAsync method with an instance of HttpRequestMessage that was constructed using HttpMethod.Head .

GetAsync, PostAsync, etc are convenient wrappers around SendAsync; the less common HTTP methods such as HEAD, OPTIONS, etc, don't get a wrapper.