Header Ads

Types of Filters in MVC

There are four types of Filters in ASP.NET MVC 4

1. Authorization Filters: Responsible for checking User Access, these implement the IAuthorizationFilter interface in the framework. The AuthorizeAttribute and RequireHttpsAttribute are examples of Authorization Filters.

2. Action Filters: These implement the IActionFilter interface that have two methods OnActionExecuting and OnActionExecuted. OnActionExecuting runs before the Action and gives an opportunity to cancel the Action call.

3. Result Filters: These implement the IResultFilter interface which like the IActionFilter has OnResultExecuting and OnResultExecuted. The OutputCacheAttribute class is example of a Result Filter.

4. ExceptionFilters: These implement the IExceptionFilter interface and they execute if there are any unhandled exceptions thrown during the execution pipeline. The HandleErrorAttribute class is an example of such a filters.

No comments:


Powered by Blogger.