Table of Contents

Class FormattedContentResult<T>

Namespace
System.Web.Http.Results
Assembly
System.Web.Http.dll

Represents an action result that returns formatted content.

public class FormattedContentResult<T> : IHttpActionResult

Type Parameters

T

The type of content in the entity body.

Inheritance
FormattedContentResult<T>
Implements
Inherited Members

Constructors

FormattedContentResult(HttpStatusCode, T, MediaTypeFormatter, MediaTypeHeaderValue, HttpRequestMessage)

Initializes a new instance of the FormattedContentResult<T> class with the values provided.

public FormattedContentResult(HttpStatusCode statusCode, T content, MediaTypeFormatter formatter, MediaTypeHeaderValue mediaType, HttpRequestMessage request)

Parameters

statusCode HttpStatusCode

The HTTP status code for the response message.

content T

The content value to format in the entity body.

formatter MediaTypeFormatter

The formatter to use to format the content.

mediaType MediaTypeHeaderValue

The value for the Content-Type header, or to have the formatter pick a default value.

request HttpRequestMessage

The request message which led to this result.

FormattedContentResult(HttpStatusCode, T, MediaTypeFormatter, MediaTypeHeaderValue, ApiController)

Initializes a new instance of the FormattedContentResult<T> class with the values provided.

public FormattedContentResult(HttpStatusCode statusCode, T content, MediaTypeFormatter formatter, MediaTypeHeaderValue mediaType, ApiController controller)

Parameters

statusCode HttpStatusCode

The HTTP status code for the response message.

content T

The content value to format in the entity body.

formatter MediaTypeFormatter

The formatter to use to format the content.

mediaType MediaTypeHeaderValue

The value for the Content-Type header, or to have the formatter pick a default value.

controller ApiController

The controller from which to obtain the dependencies needed for execution.

Properties

Content

Gets the content value to format in the entity body.

public T Content { get; }

Property Value

T

Formatter

Gets the formatter to use to format the content.

public MediaTypeFormatter Formatter { get; }

Property Value

MediaTypeFormatter

MediaType

Gets the value for the Content-Type header, or to have the formatter pick a default value.

public MediaTypeHeaderValue MediaType { get; }

Property Value

MediaTypeHeaderValue

Request

Gets the request message which led to this result.

public HttpRequestMessage Request { get; }

Property Value

HttpRequestMessage

StatusCode

Gets the HTTP status code for the response message.

public HttpStatusCode StatusCode { get; }

Property Value

HttpStatusCode

Methods

ExecuteAsync(CancellationToken)

public virtual Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task<HttpResponseMessage>