Other 3xx codes
All HTTP status codes in ASP.NET Core
3xx Redirection
The cached copy the client has is still valid (its If-None-Match or If-Modified-Since matched). No body is sent.
In ASP.NET Core: Static files handle it; for your own endpoints, compare If-None-Match with your ETag yourself.
The StatusCodes constant, HttpStatusCode enum name, reason phrase, class, and how EnsureSuccessStatusCode() and the standard resilience handler treat 304.
| Constant | StatusCodes.Status304NotModified |
|---|---|
| HttpStatusCode | HttpStatusCode.NotModified |
| Reason phrase | Kestrel sends Not Modified |
| Class | 3xx, redirection |
| IsSuccessStatusCode | false |
| EnsureSuccessStatusCode() | throws HttpRequestException: Response status code does not indicate success: 304 (Not Modified). |
| Standard resilience handler | does not retry it |
| HttpClient redirect | GET: not followed. POST: not followed. |
Results.StatusCode(StatusCodes.Status304NotModified)StatusCode(StatusCodes.Status304NotModified)Setup
app.UseStaticFiles();Request
GET /file.txt HTTP/1.1
If-None-Match: <the ETag from the previous response>Response (recorded)
HTTP/1.1 304 Not Modified
Content-Type: text/plain
Etag: "1dcb4a0f6f8e2c0"The static file middleware compares If-None-Match with the file's ETag and answers 304 with no body when it matches.
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