Skip to main content

RequestHead.Headers property

The request headers as name and value pairs.

public IReadOnlyList<KeyValuePair<string, string>> Headers { get; }

Remarks​

It is a list, not a dictionary, because a header sent more than once appears once for each value. Compare names ignoring case. Headers that describe the connection itself, such as Connection and Transfer-Encoding, are not included.

Examples​

The request's content type, or null when it has none:

string? contentType = request.Headers
.FirstOrDefault(header => header.Key.Equals("content-type", StringComparison.OrdinalIgnoreCase))
.Value;

See Also​