Search code examples
c#asp.net-corefilterattributesasp.net-mvc-filters

If I'm making a filter in an ASP.NET Core application, should I also inherit IFilterMetadata?


I've made an authorize filter (by inheriting the new IAsyncAuthorizationFilter), should I also inherit IFilterMetadata, and why/why not?

Thank you.


Solution

  • no IAsyncAuthorizationFilter already inherits IFilterMetadata

    public interface IAsyncAuthorizationFilter : Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata
    

    as MSDN indicates IFilterMetadata is a "marker" interface to indicate filter types to MVC. For an example have a look at the source of FilterCollection.