FilterContext.IsEffectivePolicy<TMetadata>(TMetadata) Method


Returns a value indicating whether the provided IFilterMetadata is the most effective policy (most specific) applied to the action associated with the FilterContext.

generic <typename TMetadata>
 where TMetadata : Microsoft::AspNetCore::Mvc::Filters::IFilterMetadata bool IsEffectivePolicy(TMetadata policy);
public bool IsEffectivePolicy<TMetadata> (TMetadata policy) where TMetadata : Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata;
member this.IsEffectivePolicy : 'Metadata -> bool (requires 'Metadata :> Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata)
Public Function IsEffectivePolicy(Of TMetadata As IFilterMetadata) (policy As TMetadata) As Boolean

Type Parameters


The type of the filter policy.



The filter policy instance.



true if the provided IFilterMetadata is the most effective policy, otherwise false.


The IsEffectivePolicy<TMetadata>(TMetadata) method is used to implement a common convention for filters that define an overriding behavior. When multiple filters may apply to the same cross-cutting concern, define a common interface for the filters (TMetadata) and implement the filters such that all of the implementations call this method to determine if they should take action.

For instance, a global filter might be overridden by placing a filter attribute on an action method. The policy applied directly to the action method could be considered more specific.

This mechanism for overriding relies on the rules of order and scope that the filter system provides to control ordering of filters. It is up to the implementor of filters to implement this protocol cooperatively. The filter system has no innate notion of overrides, this is a recommended convention.

Applies to