HttpRequestMessageExtensions.CreateContent<T> Method (HttpRequestMessage, T, IEnumerable<MediaTypeFormatter>, IFormatterSelector)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Creates a new ObjectContent instance associated with the given HttpRequestMessage.

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

public static ObjectContent<T> CreateContent<T>(
	this HttpRequestMessage request,
	T value,
	IEnumerable<MediaTypeFormatter> formatters,
	IFormatterSelector formatterSelector

Type Parameters


The type of the value.


Type: System.Net.Http.HttpRequestMessage
The HttpRequestMessage.
Type: T
The value for the new ObjectContent
Type: System.Collections.Generic.IEnumerable<MediaTypeFormatter>
The collection of MediaTypeFormatter instances to use.
Type: System.Net.Http.Formatting.IFormatterSelector
The IFormatterSelector to select the MediaTypeFormatter

Return Value

Type: System.Net.Http.ObjectContent<T>

Usage Note

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