---
title: "What are filters in MVC?"  
description: "What are filters in MVC?"  
author: "Shikhar Arora"  
published: 2019-12-25  
updated: 2019-12-25  
canonical: https://www.mindstick.com/forum/155613/what-are-filters-in-mvc  
category: "asp.net mvc"  
tags: [".net", "mvc"]  
reading_time: 3 minutes  

---

# What are filters in MVC?

[Filters](https://www.mindstick.com/forum/156119/how-to-use-filters-in-angularjs) in [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc)

## Replies

### Reply by Rahul Roi

## The types of Filters in MVC:-

Into the ASP.NET MVC framework provide the following action filters in MVC:

- (1)First is Action Filters: THE Action filters are used to implement logic that gets executed before and after a controller action executes.
- (2)Second is Authorization Filters: The Authorization filters are used to implement authentication and authorization for controller actions.
- (3)Third is Result Filters: The Result filters contain logic that is executed before and after a view result is executed. For example, you might want to modify a view result right before the view is rendered to the browser. And
- (4)Fourth is Exception Filters: Into this filter, You can use exception errors, that's raised by either your controller actions or controller action results. And also You can also use exception filters to log errors.

### Reply by Shikhar Arora

In MVC, controllers define action methods and these action methods normally have a one-to-one relationship with UI controls such as clicking a button or a link, etc. For example, in one of our previous examples, the UserController class consists of methods UserAdd, UserDelete, etc.

But many times we would like to perform some action before or after an exceptional operation. To accomplish this functionality, ASP.NET MVC provides a feature to add pre and post-action behaviors on the controller's action methods.

## Types of Filters

ASP.NET MVC framework can support the following action filters,

Action Filters

Action filters are used to apply the logic that gets executed before and after a controller action executes. We will look at Action Filters in elaboration in this chapter.

Authorization Filters

Authorization filters are used to apply authentication and authorization for controller actions.

Result Filters

Result filters comprise of logic that is executed before and after a view result is executed. For example, you might want to reform a view result right before the view is rendered to the browser.

Exception Filters

Exception filters are the last type of filter to run. You can use an exception filter to hold errors raised by either your controller actions or controller action results. You can also avail exception filters to log errors.

Action filters are one of the most commonly used filters to perform additional data processing, or manipulating the return values or canceling the execution of an action or modifying the view structure at run time.


---

Original Source: https://www.mindstick.com/forum/155613/what-are-filters-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
