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.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The types of Filters in MVC:-
Into the ASP.NET MVC framework provide the following action filters in MVC:
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.