Created
November 28, 2016 21:49
-
-
Save bymyslf/f099e4f3ec640f9116af098706e751d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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