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

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)

<ExtensionAttribute> _
Public Shared Sub AddRequestHeaderMapping ( _
	formatter As MediaTypeFormatter, _
	headerName As String, _
	headerValue As String, _
	valueComparison As StringComparison, _
	isValueSubstring As Boolean, _
	mediaType As MediaTypeHeaderValue _
Dim formatter As MediaTypeFormatter
Dim headerName As String
Dim headerValue As String
Dim valueComparison As StringComparison
Dim isValueSubstring As Boolean
Dim mediaType As MediaTypeHeaderValue

formatter.AddRequestHeaderMapping(headerName, _
	headerValue, valueComparison, isValueSubstring, _


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: MediaTypeHeaderValue
The MediaTypeHeaderValue 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.