DefaultStatusCodeAttribute Class

Definition

Specifies the default status code associated with an ActionResult.

C#
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public sealed class DefaultStatusCodeAttribute : Attribute
C#
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)]
public sealed class DefaultStatusCodeAttribute : Attribute
Inheritance
DefaultStatusCodeAttribute
Attributes

Remarks

This attribute is informational only and does not have any runtime effects. Applying the attribute on a class indicates that the ActionResult represented by that class uses a particular status code by default. Applying the attribute to a method indicates that the ActionResult returned by the method uses that status code by default. The later is helpful in scenarios where we need to specify that a method modifies the status code that an ActionResult uses by default in its logic or for specifying the status code for consumption in the API analyzers.

Constructors

Properties

StatusCode

Gets the default status code.

Applies to

Product Versions
ASP.NET Core 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0