Other 3xx codes
All HTTP status codes in ASP.NET Core
3xx Redirection
Like 301, but the client must keep the method and body.
In ASP.NET Core: Redirect(url, permanent: true, preserveMethod: true) returns it.
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 308.
| Constant | StatusCodes.Status308PermanentRedirect |
|---|---|
| HttpStatusCode | HttpStatusCode.PermanentRedirect |
| Reason phrase | Kestrel sends Permanent Redirect |
| Class | 3xx, redirection |
| IsSuccessStatusCode | false |
| EnsureSuccessStatusCode() | throws HttpRequestException: Response status code does not indicate success: 308 (Permanent Redirect). |
| Standard resilience handler | does not retry it |
| HttpClient redirect | GET: followed, as GET. POST: followed, as POST. |
Results.StatusCode(StatusCodes.Status308PermanentRedirect)
Results.Problem(statusCode: StatusCodes.Status308PermanentRedirect, detail: "...")StatusCode(StatusCodes.Status308PermanentRedirect)
Problem(statusCode: StatusCodes.Status308PermanentRedirect, detail: "...")Checked on Kestrel: Results.Redirect(url, permanent: true, preserveMethod: true), ControllerBase.RedirectPermanentPreserveMethod(url) return 308.
What Results.Problem(statusCode: 308) sends (with AddProblemDetails()), as application/problem+json:
{
"title": "Permanent Redirect",
"status": 308,
"traceId": "0HNA1B2C3D4E5:00000001"
}A controller's Problem(statusCode: 308) sends a different body, because MVC only fills type and title for codes in ApiBehaviorOptions.ClientErrorMapping:
{
"status": 308,
"traceId": "0HNA1B2C3D4E5:00000001"
}Every response on this page was recorded from ASP.NET Core 10.0.12 on Kestrel in the Production environment; the HttpClient rows come from .NET 10.0.12 and Microsoft.Extensions.Http.Resilience 10.10.0.
All HTTP status codes in ASP.NET Core