dotnet / dotnet/aspnetcore

`Microsoft.AspNetCore.Mvc.ControllerBase.Created()` returns a `StatusCodes.Status204NoContent` not `StatusCodes.Status201Created`

Open
#54,822 2 comments 2 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

There seems to be a discrepency in the docs regarding this issue. By observing the attached photo, the `ControllerBase.Created()` returns a `StatusCodes.Status204NoContent`.

image

Navigating to the documentation at the header of this function (_set the cursor on the function call and click `F12`_), it clearly states it returns a `StatusCodes.Status201Created`

image

### Expected Behavior

`ControllerBase.Created()` is expected to return what the docs adverise.

### Steps To Reproduce

[Here](https://github.com/3baaady07/TestCreatedReturnStatusCode.git) is a link to the github repository that demonstrates this issue. The repro project is the default ASP.NET Web API project scuffolded by VS2022 with controllers. The only difference is the `Test` endpoint added to `WeatherForecastController` controller as shown in the attached photo.
image

### Exceptions (if any)

_No response_

### .NET Version

8.0.202

### Anything else?

* ASP.NET 8.0.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.