Class NegotiatedContentResult<T>
Represents an action result that performs content negotiation.
public class NegotiatedContentResult<T> : IHttpActionResult
Type Parameters
T
The type of content in the entity body.
- Inheritance
-
NegotiatedContentResult<T>
- Implements
- Inherited Members
Constructors
NegotiatedContentResult(HttpStatusCode, T, IContentNegotiator, HttpRequestMessage, IEnumerable<MediaTypeFormatter>)
Initializes a new instance of the NegotiatedContentResult<T> class with the values provided.
public NegotiatedContentResult(HttpStatusCode statusCode, T content, IContentNegotiator contentNegotiator, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
Parameters
statusCode
HttpStatusCodeThe HTTP status code for the response message.
content
TThe content value to negotiate and format in the entity body.
contentNegotiator
IContentNegotiatorThe content negotiator to handle content negotiation.
request
HttpRequestMessageThe request message which led to this result.
formatters
IEnumerable<MediaTypeFormatter>The formatters to use to negotiate and format the content.
NegotiatedContentResult(HttpStatusCode, T, ApiController)
Initializes a new instance of the NegotiatedContentResult<T> class with the values provided.
public NegotiatedContentResult(HttpStatusCode statusCode, T content, ApiController controller)
Parameters
statusCode
HttpStatusCodeThe HTTP status code for the response message.
content
TThe content value to negotiate and format in the entity body.
controller
ApiControllerThe controller from which to obtain the dependencies needed for execution.
Properties
Content
Gets the content value to negotiate and format in the entity body.
public T Content { get; }
Property Value
- T
The content value to negotiate and format in the entity body.
ContentNegotiator
Gets the content negotiator to handle content negotiation.
public IContentNegotiator ContentNegotiator { get; }
Property Value
- IContentNegotiator
The content negotiator to handle content negotiation.
Formatters
Gets the formatters to use to negotiate and format the content.
public IEnumerable<MediaTypeFormatter> Formatters { get; }
Property Value
- IEnumerable<MediaTypeFormatter>
The formatters to use to negotiate and format the content.
Request
Gets the request message which led to this result.
public HttpRequestMessage Request { get; }
Property Value
- HttpRequestMessage
The HTTP request message which led to this result.
StatusCode
Gets the HTTP status code for the response message.
public HttpStatusCode StatusCode { get; }
Property Value
- HttpStatusCode
The HTTP status code for the response message.
Methods
ExecuteAsync(CancellationToken)
Executes asynchronously an HTTP negotiated content results.
public virtual Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<HttpResponseMessage>
Asynchronously executes an HTTP negotiated content results.