Share via

HttpClient.Send not supported in mac

Dani_S 5,581 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

Answer accepted by question author

  1. Michael Taylor 61,221 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.