Export (0) Print
Expand All

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)

'Declaration
<ExtensionAttribute> _
Public Shared Sub AddRequestHeaderMapping ( _
	formatter As MediaTypeFormatter, _
	headerName As String, _
	headerValue As String, _
	valueComparison As StringComparison, _
	isValueSubstring As Boolean, _
	mediaType As MediaTypeHeaderValue _
)
'Usage
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, _
	mediaType)

Parameters

formatter
Type: System.Net.Http.Formatting.MediaTypeFormatter
The MediaTypeFormatter to receive the new MediaRangeMapping item.
headerName
Type: System.String
Name of the header to match.
headerValue
Type: System.String
The header value to match.
valueComparison
Type: System.StringComparison
The StringComparison to use when matching headerValue.
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 https://msdn.microsoft.com/en-us/library/bb384936(v=vs.108).aspx or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.108).aspx.

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

Show:
© 2015 Microsoft