HttpResponseMessage
noun
say it: “AYCH-TEE-TEE-PEE rih-SPONS MES-ij” /ˌeɪtʃ tiː tiː ˈpiː rɪˈspɒns ˈmɛsɪdʒ/
The object HttpClient returns for a response, holding its status code, headers and body.
What is HttpResponseMessage in C#?
HttpResponseMessage — The object HttpClient gives back for each response. It holds the status code, the headers and the body, so you can check IsSuccessStatusCode before reading the content.
HttpResponseMessage response = await client.GetAsync("api/products/999");
Console.WriteLine((int)response.StatusCode); // 404
if (response.IsSuccessStatusCode) { /* read the body */ }
In a sentence
- “The HttpResponseMessage had status 404, so I didn't try to read a product.”
Level: Journeyman · More C# terms at this level
Updated