MVC Developer Question:

Tell us what are Action Filters in MVC?

Tweet Share WhatsApp

Answer:

Action Filters are additional attributes that can be applied to either a controller section or the entire controller to modify the way in which action is executed. These attributes are special .NET classes derived from System.Attribute which can be attached to classes, methods, properties and fields.

Output Cache: This action filter caches the output of a controller action for a specified amount of time.

Handle Error: This action filter handles errors raised when a controller action executes.

Authorize: This action filter enables you to restrict access to a particular user or role.

Now we will see the code example to apply these filters on an example controller ActionFilterDemoController. (ActionFilterDemoController is just used as an example. You can use these filters on any of your controllers.)

Download MVC Developer PDF Read All 50 MVC Developer Questions
Previous QuestionNext Question
Tell me what are HTML helpers in MVC?Tell me what are the Folders in MVC application solutions?