View component
A view component is a reusable user-interface unit that encapsulates presentation logic for rendering a portion of a page or response.
Pro ASP.NET Core 7, Tenth Edition
The ViewComponent base class is the ASP.NET Core MVC base class that supplies view-component behavior and access to request context.
- How it is used
- Supplies reusable navigation and cart-summary content inside layouts without making it part of each action’s view model.
- How deep it goes
- Works through class discovery, injected data, Razor rendering, parent arguments, and request context rather than framework internals.
- Examples
- Builds category navigation and a shopping-cart summary, then demonstrates an asynchronous page-size display.
- What you can do after
- Build it from scratch: inject a service, implement Invoke, render a Razor view, and embed the result in a layout.
Read how Pro ASP.NET Core 7, Tenth Edition explains view component →
ASP.NET Core in Action, 3e
ViewComponent is the ASP.NET Core base class from which custom view component classes can derive.
- How it is used
- Uses view components to render independent, logic-rich regions without burdening the main Razor page.
- How deep it goes
- Explains component creation, dependency injection, view location, parameter passing, and invocation with a worked recipe example.
- Examples
- Uses a current-user recipe component alongside shopping carts, dynamic menus, and login widgets as examples.
- What you can do after
- Build view components from scratch by deriving from ViewComponent, implementing InvokeAsync(), and invoking them from Razor views.
Read how ASP.NET Core in Action, 3e explains view component →
Related concepts
- dependency injectionuses · Dependency injection is a software design technique in which a component receives its dependencies from outside rather than creating or locating them internally.
- subtemplatecontrasts with · A subtemplate is a reusable template fragment that can be rendered independently or included within another template to produce part of an output.
- contextuses · Context is the information, state, or circumstances surrounding a situation or input that influence its interpretation, decisions, or behavior.
- Invoke methoduses · Invoke is the conventional ASP.NET Core middleware method that processes an HTTP request and can receive dependencies through its parameters.
- InvokeAsyncused by · InvokeAsync is an API method for invoking an operation asynchronously and obtaining or scheduling its result.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

