-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
StatusCode is not set for CreatedResult()
var result = new CreatedResult();
// result.StatusCode == null
Expected Behavior
var result = new CreatedResult();
// result.StatusCode == 201
Steps To Reproduce
Simple to fix.
Change
public class CreatedResult : ObjectResult
{
private const int DefaultStatusCode = StatusCodes.Status201Created;
private string? _location;
/// <summary>
/// Initializes a new instance of the <see cref="CreatedResult"/> class
/// </summary>
public CreatedResult()
: base(null)
{
}to
public class CreatedResult : ObjectResult
{
private const int DefaultStatusCode = StatusCodes.Status201Created;
private string? _location;
/// <summary>
/// Initializes a new instance of the <see cref="CreatedResult"/> class
/// </summary>
public CreatedResult()
: base(DefaultStatusCode)
{
}Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.