-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
There's a difference in antiforgery prevention response between classic MVC and API controllers and minimal APIs.
- Controller: 400 Bad Request
- Minimal API: 500 Internal Server Error
Expected Behavior
I expect the antiforgery validation failure response to be consistent between backend implementations so that I can write a frontend that is ignorant of the technology used in the backend.
Steps To Reproduce
Controller
[ApiController]
[Route("example-1")]
public class AntiforgeryExampleController : ControllerBase
{
[HttpPost]
[RequireAntiforgeryToken]
public IActionResult Post(IFormFile file)
{
return Ok();
}
}
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "Bad Request",
"status": 400
}
Minimal API
app.MapPost("example-2", (IFormFile file) => Results.Ok());
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.6.1",
"title": "An error occurred while processing your request.",
"status": 500
}
Exceptions (if any)
No response
.NET Version
8.0.403
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc