HttpClient.Send not supported in mac

Dani_S 4,501 Reputation points
2024-06-17T12:39:02.6033333+00:00

Hi,

HttpClient.Send(request. HttpCompletionOption.ResponseHeaderRead) => not supported in mac

why? it work on windows.

Developer technologies .NET .NET MAUI
{count} votes

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2024-06-18T21:10:23.4466667+00:00

    You're trying to use the sync version of the method. Sync methods, in general, are not recommended. For Mac you must use the async version (SendAsync).

    //HttpResponseMessage httpResponse = _client.Send(request, HttpCompletionOption.ResponseHeadersRead); 
    HttpResponseMessage httpResponse = await _client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
    

    You can read more here about why this decision was made but honestly nobody uses Send anyway and you're in the middle of an async all so there is no reason to use the sync version.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.