Last active
December 21, 2015 08:19
-
-
Save DavidDeSloovere/6277610 to your computer and use it in GitHub Desktop.
System.Net.HttpResponseMessage set custom status code like 429
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
var response = new HttpResponseMessage | |
{ | |
StatusCode = (HttpStatusCode)429, | |
ReasonPhrase = "Too Many Requests", | |
Content = new StringContent(string.Format(CultureInfo.InvariantCulture, "Rate limit reached. Reset in {0} seconds.", data.ResetSeconds)) | |
}; | |
response.Headers.Add("Retry-After", data.ResetSeconds.ToString(CultureInfo.InvariantCulture)); | |
actionContext.Response = response; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment