MediaTypeFormatterExtensions.AddRequestHeaderMapping Method (MediaTypeFormatter, String, String, StringComparison, Boolean, String)

Updates the given set of formatter of MediaTypeMapping elements so that it associates the mediaType with a specific HTTP request header field with a specific value.

Namespace:  System.Net.Http.Formatting
Assembly:  System.Net.Http.Formatting (in System.Net.Http.Formatting.dll)

public static function AddRequestHeaderMapping(
	formatter : MediaTypeFormatter, 
	headerName : String, 
	headerValue : String, 
	valueComparison : StringComparison, 
	isValueSubstring : boolean, 
	mediaType : String


Type: System.Net.Http.Formatting.MediaTypeFormatter
The MediaTypeFormatter to receive the new MediaRangeMapping item.
Type: System.String
Name of the header to match.
Type: System.String
The header value to match.
Type: System.StringComparison
The StringComparison to use when matching headerValue.
Type: System.Boolean
if set to true then headerValue is considered a match if it matches a substring of the actual header value.
Type: System.String
The media type to associate with a Header() entry with a name matching headerName and a value matching headerValue.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type MediaTypeFormatter. When you use instance method syntax to call this method, omit the first parameter. For more information, see or

RequestHeaderMapping checks header fields associated with Headers() for a match. It does not check header fields associated with Headers() or Headers() instances.