I'm trying to make a HEAD
request to Google.com.
This is my code:
using (var client = new HttpClient())
{
var m = new HttpRequestMessage(HttpMethod.Head, "http://google.com");
var resp = await client.SendAsync(m);
return true;
}
When I execute this code I get the following exception:
System.Net.WebException: The request requires buffering data to succeed.
at System.Net.HttpWebRequest.Redirect (System.Net.WebAsyncResult result, HttpStatusCode code, System.Net.WebResponse response) [0x00000] in :0
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in :0
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in :0
I can't understand why... Google accept Head requests because using Postman I get a 200 OK
code
Can you help me?
200 OK
back. – Yuval ItzchakovWebRequest
– user3471528