Thursday 3 December 2015

ASP.NET MVC Action Filter


ASP.NET MVC Filters allow us to inject extra logic into MVC Framework request processing, this logic either before or after an action is executed. 

I will show you the different categories of filters that the MVC Framework supports, how to create and use filters, and how to control their execution. We can make your own custom filters or attributes either by implementing ASP.NET MVC filter interface or by inheriting and overriding methods of ASP.NET MVC filter attribute class if available.


Understanding the Four Basic Types of Filters

The ASP.NET MVC Framework supports four different types of filters. Each allows you to introduce logic at different points during request processing. The four filter types are described in Table.
All ASP.NET MVC filter are executed in an order. Following list shows the order in which ASP.NET MVC Filters are executing.
  1. Authentication filters
  2. Authorization filters
  3. Action filters
  4. Result filters