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, _
public static void AddRequestHeaderMapping(
    this MediaTypeFormatter formatter,
    string headerName,
    string headerValue,
    StringComparison valueComparison,
    bool isValueSubstring,
    MediaTypeHeaderValue mediaType
static void AddRequestHeaderMapping(
    MediaTypeFormatter^ formatter, 
    String^ headerName, 
    String^ headerValue, 
    StringComparison valueComparison, 
    bool isValueSubstring, 
    MediaTypeHeaderValue^ mediaType
static member AddRequestHeaderMapping : 
        formatter:MediaTypeFormatter * 
        headerName:string * 
        headerValue:string * 
        valueComparison:StringComparison * 
        isValueSubstring:bool * 
        mediaType:MediaTypeHeaderValue -> unit 
public static function AddRequestHeaderMapping(
    formatter : MediaTypeFormatter, 
    headerName : String, 
    headerValue : String, 
    valueComparison : StringComparison, 
    isValueSubstring : boolean, 
    mediaType : MediaTypeHeaderValue


  • isValueSubstring
    Type: System.Boolean
    if set to true then headerValue is considered a match if it matches a substring of the actual header value.
  • mediaType
    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.

See Also


MediaTypeFormatterExtensions Class

AddRequestHeaderMapping Overload

System.Net.Http.Formatting Namespace