Filters in mvc

there are different types of filters in mvc,the execution of filters below like

A)Authorization filters: this filter implements using IAithorizationFilter , it is used to secure action like performing authentication and validationit is used by Authorize attribute , below is the example of using this attribute .

public ActionResult Authenticateuser()
return View();

Diffrent roles based authorization can be done like

Authorize(Roles = “Admin, Super User”)]

Required Https attribute is another type Authorization filter.

B)Action Filter: It will come after authorization filter and it wraps IActionFilter Interface which declares two method OnActionExecuting and OnActionExecuted, in this method extra data can be added .

C)ResultFilter: It also come after Action Filter , it uses IResultFilter interface and     uses OnResultExecuting and OnResulExecuted    , output cahche can be a good resultfilter example.

D)Exception Filters: It is the last filter which handles error and unhanded exception    , the handleerrorattribute is good example for exception filter.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>