The ASP.NET MVC has many types of action filters.Some of the main action filters are discussed below.Apart from this you can also create your custom action filter.Some of the examples of custom action filter are building a custom authentication system using custom action filter. You can think of your own situation of doing custom action filter on entire controller or controller action methods.
Let me know your thoughts through Twitter:-


Different types of Action Filters in MVC

  • Output cache
  • Handle Error
  • Authorize

Output Cache: This action filter caches the output of a controller action for a specified amount of time.The following example caches output of view for 1 hour.Instead of giving duration as 1 hour in cache attribute of every action methods used in all controllers of the project.I have mentioned cacheprofile as 1 hour in one central place i.e web.config.

            
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="cache1Hour" duration="3600" >
<outputCacheProfiles>
<outputCacheSettings>
<caching>
    
        

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

[HandleError]
public class differentangularModulesController : Controller
{
// GET: differentangularModules
//  [OutputCache(CacheProfile ="cache1hour")]
public ActionResult Index()
{
                 
}
}
        

and the output is:

Authorize: This action filter restrict access to particular user or role.After registered user logs in to the system , it displays particular page. It allows only authorized users to logged into the system or application.

[Authorize]
public class HomeController : Controller
{                     
public ActionResult Index()
{
return View();
}
}