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]().

Syntax

public class ProducesAttribute : ResultFilterAttribute, _Attribute, IResultFilter, IAsyncResultFilter, IOrderedFilter, IFilter, IApiResponseMetadataProvider

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.ProducesAttribute

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)

Properties

ContentTypes()
Return type:System.Collections.Generic.IList{MediaTypeHeaderValue}
public IList<MediaTypeHeaderValue> ContentTypes { get; set; }
Type()
Return type:System.Type
public Type Type { get; set; }

Methods

OnResultExecuting(Microsoft.AspNet.Mvc.ResultExecutingContext)
Arguments:
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)