Sunday, 11 May 2014

Filters in MVC 4

Authorization Filters :

These filters implement and make security decisions about whether to execute an action method, such as performing authentication or validating properties of the request.

Action Filters :

Action Filters are attributes that can be applied either on a controller action method or on a controller. When applied at the controller level, they are applicable for all action methods with in that controller. Action Filters allow us to add, pre and post processing logic to an action method. This means they allow us to modify the way in which the action is executed.

Result Filters :

Result filters are executed before or after generating the result for an action. The Action Result type can be ViewResult, PartialViewResult, RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, FileResult and EmptyResult which derives from the ActionResult class. Result filters are called after the Action filters. The IResultFilter interface is used to create an Result Filter which provides two methods OnResultExecuting and OnResultExecuted which will be executed before or after generating the result for an action respectively.

Exception Filters :


Exception filters are executed when exception occurs during the actions execution or filters execution. The IExceptionFilter interface is used to create an Exception Filter which provides OnException method which will be executed when exception occurs during the actions execution or filters execution.

tags: filters in mvc 4,filters in mvc 5,action filters in mvc 4,action filters in mvc4,filters resultfilers,customfilters,actionfilters,filters in mvc,mvc fiulters ,actionfilters in mvc,actionfilters in mvc 5,filters in mvc ,authorize filters,resultfilters,outputcache filters in asp.netmvc ,filters  in asp.net mvc 5,action filters in asp.net mvc 4,filters in asp.net mvc 6,handle error filter in asp.net mvc,validate anti forgery token in asp.net mvc 5,validate anti forgery token in asp.net mvc 6,validate anti forgery token in asp.net mvc 4,action filters in asp.net mvc 5,action filters in asp.net mvc 5,action filters in asp.net mvc 4,types of action filters in asp.net mvc 5,types of action filters in asp.net mvc 4,types of action filters in asp.net mvc 6