// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; namespace System.Web.Http { /// /// An action result that performs content negotiation. /// /// The type of content in the entity body. public class NegotiatedContentResult : ObjectResult { /// /// Initializes a new instance of the class with the values provided. /// /// The HTTP status code for the response message. /// The content value to negotiate and format in the entity body. public NegotiatedContentResult(HttpStatusCode statusCode, T content) : base(content) { StatusCode = (int)statusCode; Content = content; } /// /// Gets the content value to negotiate and format in the entity body. /// public T Content { get; private set; } /// public override Task ExecuteResultAsync(ActionContext context) { context.HttpContext.Response.StatusCode = (int)StatusCode; return base.ExecuteResultAsync(context); } } }