Wednesday 10 August 2016

Action Filter in ASP.NET MVC

Posted by : Manav Pandya
Action Filter in ASP.NET MVC

How to define Action Filter in ASP.NET MVC 

Action filters are execute before or after an action is executed.


The [ IActionFilter ] interface is used to create an Action Filter which provides two methods [ OnActionExecuting ] and [ OnActionExecuted ] which will be executed before or after an action is executed simultaneously .


These attributes are special .NET classes derived from [ System.Attribute ] which can be attached to classes , methods , properties and fields.

Normally It Provides following methods :


  • OnActionExcuting - This method runs before execution of any action 
  • OnActionExcuted - This method runs after execution of any action . 

ASP.NET MVC ,   .NET Core , Razor  , Dapper , CRUD ,