What is Filter?
It provides a way to inject extra logic at different levels of ASP.NET MVC framework after the action is executed.
Types of filters
There are five types of filters available in the ASP.NET MVC 5: 1. Authentic ation filters 2. Authorization filters 3. Action filters 4. Result filters 5. Exception filters
The validity of the user making the request is verified by this filter. All filters and action methods are invoked after the authentication filter.
This filter is used to determine if the user is authorized to access a specific page or resource. For controller activities, these filters were utilized to implement authentication and authorization.
Depending on the situation, a controller's entire action set or only a specific action can be applied to an action filter. Before or after the action method has finished executing, the action filters in an ASP.NET MVC application will be executed.
These filters have logic that runs both before and after a view result. Consider the case when you wish to alter a view result just before the view is displayed to the browser, this filter is utilized.
These filters can be used as an exception filters to deal with any unhandled exception brought on by your controller actions or their results.