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.
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.
Liked By
Write Answer
What are filters in MVC?
Join MindStick Community
You have need login or register for voting of answers or question.
Rahul Roi
27-Oct-2020The types of Filters in MVC:-
Into the ASP.NET MVC framework provide the following action filters in MVC:
Shikhar Arora
25-Dec-2019In 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.