Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MediaTypeFormatter.SetDefaultContentHeaders Method

Sets the default headers for content that will be formatted using this formatter. This method is called from the ObjectContent constructor. This implementation sets the Content-Type header to the value of mediaType if it is not null. If it is null it sets the Content-Type to the default media type of this formatter. If the Content-Type does not specify a charset it will set it using this formatters configured Encoding.

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

'Declaration
Public Overridable Sub SetDefaultContentHeaders ( _
	type As Type, _
	headers As HttpContentHeaders, _
	mediaType As MediaTypeHeaderValue _
)
'Usage
Dim instance As MediaTypeFormatter 
Dim type As Type 
Dim headers As HttpContentHeaders 
Dim mediaType As MediaTypeHeaderValue

instance.SetDefaultContentHeaders(type, _
	headers, mediaType)

Parameters

type
Type: System.Type

The type of the object being serialized. See ObjectContent.

headers
Type: HttpContentHeaders

The content headers that should be configured.

mediaType
Type: MediaTypeHeaderValue

The authoritative media type. Can be null.

Subclasses can override this method to set content headers such as Content-Type etc. Subclasses should call the base implementation. Subclasses should treat the passed in mediaType (if not null) as the authoritative media type and use that as the Content-Type.

Show:
© 2015 Microsoft