[.NET 8][MVC] Created() method on IActionResult returns 204NoContent StatusCode
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
.NET 8. When controller endpoint has return type `IActionResult` and return object is made by parameterless Created() method, response status code is 204. The workaround is following:
```csharp
return Created((string)null, null);
```
### Expected Behavior
I do not mean, that when there is no content in the response, then NoContent should not be returned, but when I explicitly want to return 201, I would expect 201, otherwise it's a breaking change for the contract of our WebAPI.
### Steps To Reproduce
```csharp
[HttpPost("TestB")]
public IActionResult Post()
{
return Created();
}
```
### Exceptions (if any)
_No response_
### .NET Version
8.0.400
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.