Using Child Actions

Child actions are action methods that we invoke from within a view. This lets us avoid repeating logic in our controller that we want to use in several places in the application.

images Note Child actions are to actions as partial views are to views. See Chapter 25 for details of partial views.

We might use a child action whenever we want to display some data-driven “widget” that appears on multiple pages and contains data unrelated to the main action that is running. This is commonly the case when we want part of the overall page to contain navigation links, where the data required to create navigation links is unrelated to the ...

Get Applied ASP.NET 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.