ProducesAttribute Class¶
A filter that specifies the expected System.Type
the action will return and the supported
response content types. The Microsoft.AspNetCore.Mvc.ProducesAttribute.ContentTypes
value is used to set
Microsoft.AspNetCore.Mvc.ObjectResult.ContentTypes
.
- Namespace
Microsoft.AspNetCore.Mvc
- Assemblies
- Microsoft.AspNetCore.Mvc.Core
Inheritance Hierarchy¶
System.Object
System.Attribute
Microsoft.AspNetCore.Mvc.Filters.ResultFilterAttribute
Microsoft.AspNetCore.Mvc.ProducesAttribute
Syntax¶
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ProducesAttribute : ResultFilterAttribute, _Attribute, IResultFilter, IAsyncResultFilter, IOrderedFilter, IFilterMetadata, IApiResponseMetadataProvider
-
class
Microsoft.AspNetCore.Mvc.
ProducesAttribute
Constructors¶
-
ProducesAttribute
(System.String, System.String[])¶ Initializes an instance of
Microsoft.AspNetCore.Mvc.ProducesAttribute
with allowed content types.Arguments: - contentType (System.String) – The allowed content type for a response.
- additionalContentTypes (System.String<System.String>[]) – Additional allowed content types for a response.
public ProducesAttribute(string contentType, params string[] additionalContentTypes)
-
ProducesAttribute
(System.Type) Initializes an instance of
Microsoft.AspNetCore.Mvc.ProducesAttribute
.Arguments: type (System.Type) – The Microsoft.AspNetCore.Mvc.ProducesAttribute.Type
of object that is going to be written in the response.public ProducesAttribute(Type type)
-
Properties¶
-
Microsoft.AspNetCore.Mvc.ProducesAttribute.
ContentTypes
¶ Gets or sets the supported response content types. Used to set
Microsoft.AspNetCore.Mvc.ObjectResult.ContentTypes
.Return type: Microsoft.AspNetCore.Mvc.Formatters.MediaTypeCollection public MediaTypeCollection ContentTypes { get; set; }
-
Microsoft.AspNetCore.Mvc.ProducesAttribute.
StatusCode
¶ Return type: System.Int32 public int StatusCode { get; }
-
Microsoft.AspNetCore.Mvc.ProducesAttribute.
Type
¶ Return type: System.Type public Type Type { get; set; }
-