Posts

Showing posts with the label Filters in MVC

What are Filters in MVC?

In MVC, controllers define action methods and these action methods generally 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 contained methods UserAdd, UserDelete, etc. But many times we would like to perform some action before or after a particular operation. For achieving this functionality, ASP.NET MVC provides feature to add pre and post action behaviors on controller's action methods. Types of Filters: ASP.NET MVC framework supports the following action filters: Action Filters:  Action filters are used to implement logic that gets executed before and after a controller action executes. We will look at Action Filters in detail in this chapter. Authorization Filters:  Authorization filters are used to implement authentication and authorization for controller actions. Result Filters:  Result filters contain logic that is executed before and after a view...