concept action filter in category c#

appears as: ction filters, Action filters, n action filter, action filter, action filters, ction filter
ASP.NET 4.0 in Practice

This is an excerpt from Manning's book ASP.NET 4.0 in Practice.

Action filters are classes that inherit from the infrastructural ActionFilterAttribute class and provide entry points to inject logic during the execution of an action. Their base class exposes four virtual methods, listed in Table 9.1, which are automatically triggered by the ASP.NET MVC execution engine while processing a request.

Figure 9.8. Entry points for action filters to inject code during the request flow
ASP.NET MVC 2 in Action

This is an excerpt from Manning's book ASP.NET MVC 2 in Action.

The ActionResult is one of those extensibility points that can reduce an action’s complexity. We’ll cover how attributes placed on an action method are used to modify its behavior, including action selectors that can determine which action should be executed and action filters that can modify the model returned from an action.

The easiest way to implement an action filter is to create a class that inherits from ActionFilterAttribute, although it’s also possible to override methods on the Controller class itself.

Listing 19.3. Applying an action filter to a controller action
[SubtitleData] public ActionResult About() { return View(); }
Listing 23.11. Action filters applied to controller to keep concerns separated
ASP.NET MVC in Action with MvcContrib, NHibernate, and More

This is an excerpt from Manning's book ASP.NET MVC in Action with MvcContrib, NHibernate, and More.

Using these methods you can keep your controller actions and the associated views organized. One method we used was overriding the OnActionExecuting event to preload data. What if we needed this data to be used for actions in other controllers? For that matter, just about any code that we write in an OnActionExecuting handler could be reused in other controllers. To accomplish that reuse, we can leverage action filters.

7.3. Using action filters to load common data

Chapter 6 introduced you to action filters. We can leverage action filters to provide common logic that can be executed across many controllers. Listing 7.11 shows an action filter that loads sponsors into ViewData.