Export (0) Print
Expand All

FilterAttribute Class

Represents the base class for action and result filter attributes.

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

[<AbstractClassAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Method, Inherited = true, 
    AllowMultiple = false)>]
type FilterAttribute =  
    class 
        inherit Attribute 
        interface IMvcFilter 
    end

The FilterAttribute type exposes the following members.

  NameDescription
Protected methodFilterAttributeInitializes a new instance of the FilterAttribute class.
Top

  NameDescription
Public propertyAllowMultipleGets or sets a value that indicates whether more than one instance of the filter attribute can be specified.
Public propertyOrderGets or sets the order in which the action filters are executed.
Public propertyTypeId (Inherited from Attribute.)
Top

  NameDescription
Public methodEquals (Inherited from Attribute.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Attribute.)
Public methodGetType (Inherited from Object.)
Public methodIsDefaultAttribute (Inherited from Attribute.)
Public methodMatch (Inherited from Attribute.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

Typically, you create a filter by creating an attribute class that inherits from the abstract FilterAttribute class. Some built-in action filters, such as AuthorizeAttribute and HandleErrorAttribute, inherit from the FilterAttribute class. Other action filters, such as OutputCacheAttribute, inherit from the abstract ActionFilterAttribute class, which enables the action filter to run either before or after the action method runs.

You can use filter attributes to mark any action method or controller. If the attribute marks a controller, the filter applies to all action methods in that controller.

For more information about how to use attributes, see Extending Metadata Using Attributes.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft