Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have used Accepts extension method to allow only specific Content-Type. Refer below code snippet for reference.
webApplication.MapPost("v1/todo", async (long id, [FromBody] TODO request) => { // Perform operation }) .Accepts<TODO>("application/json") .Produces(StatusCodes.Status415UnsupportedMediaType);
But this Accepts doesn't handle null Content-Type in header.
Expected Behavior
Should throw 415 if define Content-type is not passed in header.
Steps To Reproduce
- Use extension method
Accepts
which supports only specific Content-Type otherwise throw 415. Here i have takenapplication/json
. - Now make API request without request body(body is null) and Content-Type is also null
- Verify response
Exceptions (if any)
No response
.NET Version
6.0.101
Anything else?
No response