FormatFilter Class¶
Summary¶
A filter which will use the format value in the route data or query string to set the content type on an [Microsoft.AspNet.Mvc.ObjectResult]() returned from an action.
Inheritance Hierarchy¶
System.Object
Microsoft.AspNet.Mvc.FormatFilter
Constructors¶
-
FormatFilter
(IOptions<Microsoft.AspNet.Mvc.MvcFormatterMappingOptions>, Microsoft.AspNet.Mvc.IScopedInstance<Microsoft.AspNet.Mvc.ActionContext>)¶ Initializes an instance of [Microsoft.AspNet.Mvc.FormatFilter](Microsoft.AspNet.Mvc.FormatFilter.yml).
Arguments: - options (IOptions{Microsoft.AspNet.Mvc.MvcFormatterMappingOptions}) – The <see cref=”!:IOptions<MvcOptions>” />
- actionContext (Microsoft.AspNet.Mvc.IScopedInstance{Microsoft.AspNet.Mvc.ActionContext}) – The [Microsoft.AspNet.Mvc.IScopedInstance`1]()
public FormatFilter(IOptions<MvcFormatterMappingOptions> options, IScopedInstance<ActionContext> actionContext)
-
Properties¶
-
ContentType
()¶ @!:MediaTypeHeaderValue- for the format value in the current request.
Return type: MediaTypeHeaderValue public MediaTypeHeaderValue ContentType { get; }
-
Format
()¶ Format value in the current request. <c>null</c> if format not present in the current request.
Return type: System.String public string Format { get; }
-
IsActive
()¶ <c>true</c> if the current [Microsoft.AspNet.Mvc.FormatFilter](Microsoft.AspNet.Mvc.FormatFilter.yml) is active and will execute.
Return type: System.Boolean public bool IsActive { get; }
-
Methods¶
-
OnResourceExecuted
(Microsoft.AspNet.Mvc.ResourceExecutedContext)¶ Arguments: - context (Microsoft.AspNet.Mvc.ResourceExecutedContext) –
public void OnResourceExecuted(ResourceExecutedContext context)
-
OnResourceExecuting
(Microsoft.AspNet.Mvc.ResourceExecutingContext)¶ As a [Microsoft.AspNet.Mvc.IResourceFilter](), this filter looks at the request and rejects it before going ahead if 1. The format in the request doesnt match any format in the map. 2. If there is a conflicting producesFilter.
Arguments: - context (Microsoft.AspNet.Mvc.ResourceExecutingContext) – The [Microsoft.AspNet.Mvc.ResourceExecutingContext]().
public void OnResourceExecuting(ResourceExecutingContext context)
-
OnResultExecuted
(Microsoft.AspNet.Mvc.ResultExecutedContext)¶ Arguments: - context (Microsoft.AspNet.Mvc.ResultExecutedContext) –
public void OnResultExecuted(ResultExecutedContext context)
-
OnResultExecuting
(Microsoft.AspNet.Mvc.ResultExecutingContext)¶ Sets a Content Type on an [Microsoft.AspNet.Mvc.ObjectResult]() using a format value from the request.
Arguments: - context (Microsoft.AspNet.Mvc.ResultExecutingContext) – The [Microsoft.AspNet.Mvc.ResultExecutingContext]().
public void OnResultExecuting(ResultExecutingContext context)
-