var request = new HttpRequestMessage(HttpMethod.Post, uri); request.Content = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); request.Content.Headers.ContentType.MediaType = new MediaTypeHeaderValue("application/json");
var response = await httpClient.GetAsync(uri); var contentTypeHeader = response.Content.Headers.ContentType; var mediaType = contentTypeHeader.MediaType; var charset = contentTypeHeader.CharSet;In this example, we use the ContentType property of the HttpContent class to retrieve the MediaTypeHeaderValue object representing the content type header of the response. We can then access the MediaType and CharSet properties to extract the media type and the character set parameter. Overall, the MediaTypeHeaderValue class provides convenient methods for working with media type headers in HTTP requests and responses.