Skip to content

Instantly share code, notes, and snippets.

@bymyslf
Created November 28, 2016 21:49
Show Gist options
  • Save bymyslf/f099e4f3ec640f9116af098706e751d8 to your computer and use it in GitHub Desktop.
Save bymyslf/f099e4f3ec640f9116af098706e751d8 to your computer and use it in GitHub Desktop.
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
public class NotAcceptableResult : IHttpActionResult
{
private readonly HttpRequestMessage request;
public NotAcceptableResult(HttpRequestMessage request)
{
this.request = request;
}
public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
{
var response = this.request.CreateResponse(HttpStatusCode.NotAcceptable);
return Task.FromResult(response);
}
}
public static class ApiControllerExtensions
{
public static NotAcceptableResult NotAcceptable(this ApiController controller)
{
return new NotAcceptableResult(controller.Request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment