ProducesAttribute Class¶
Summary¶
Specifies the allowed content types and the type of the value returned by the action which can be used to select a formatter while executing [Microsoft.AspNet.Mvc.ObjectResult]().
Inheritance Hierarchy¶
System.Object
System.Attribute
Microsoft.AspNet.Mvc.ResultFilterAttribute
Microsoft.AspNet.Mvc.ProducesAttribute
Syntax¶
public class ProducesAttribute : ResultFilterAttribute, _Attribute, IResultFilter, IAsyncResultFilter, IOrderedFilter, IFilter, IApiResponseMetadataProvider
Constructors¶
-
ProducesAttribute
(System.String, System.String[])¶ Initializes an instance of [Microsoft.AspNet.Mvc.ProducesAttribute](Microsoft.AspNet.Mvc.ProducesAttribute.yml) with allowed content types.
Arguments: - contentType (System.String) – The allowed content type for a response.
- additionalContentTypes (System.String[]) – Additional allowed content types for a response.
public ProducesAttribute(string contentType, params string[] additionalContentTypes)
-
ProducesAttribute
(System.Type) Initializes an instance of [Microsoft.AspNet.Mvc.ProducesAttribute](Microsoft.AspNet.Mvc.ProducesAttribute.yml).
Arguments: - type (System.Type) – The [Microsoft.AspNet.Mvc.ProducesAttribute.Type](Microsoft.AspNet.Mvc.ProducesAttribute.yml) of object that is going to be written in the response.
public ProducesAttribute(Type type)
-
Methods¶
-
OnResultExecuting
(Microsoft.AspNet.Mvc.ResultExecutingContext)¶ Arguments: - context (Microsoft.AspNet.Mvc.ResultExecutingContext) –
public override void OnResultExecuting(ResultExecutingContext context)
-
SetContentTypes
(System.Collections.Generic.IList<MediaTypeHeaderValue>)¶ Arguments: - contentTypes (System.Collections.Generic.IList{MediaTypeHeaderValue}) –
public void SetContentTypes(IList<MediaTypeHeaderValue> contentTypes)
-