What is a partial view, and how does it differ from a view component?

ASP.NET MVC Views & Razor Basic 1–2 Yrs2–3 Yrs Conceptual 1 min read

Quick Answer

A partial view is a reusable chunk of Razor markup rendered inside another view, sharing the parent's model or a passed-in model — pure presentation, no logic of its own. A view component is a partial view plus a class that runs its own logic (query a service, build a model) — use it when the fragment needs data the parent doesn't have.

A partial view is a reusable piece of Razor — a card, a table row — that renders inside a parent view and uses the parent's model or one I pass in. It has no logic of its own. A view component is the next step up: it's a partial plus a small class with an InvokeAsync method that can use dependency injection to fetch its own data. So I use a partial when the parent already has the data, and a view component for something like a cart summary or a navigation menu that needs to query a service independently. View components replaced the old child actions from MVC 5.

  • Partial view — <partial name="_OrderRow" model="order" /> or @await Html.PartialAsync(...). Good for repeating layout (a card, a table row).
  • View component — public class CartSummaryViewComponent : ViewComponent with an InvokeAsync() that fetches the cart and returns View(model). Invoked with <vc:cart-summary />. It has DI, can be async, and isn't reachable as a URL.
  • The old Html.Action / child actions (MVC 5) were replaced by view components in Core.
  • Html.Partial returns a string; Html.RenderPartial writes directly to the response (slightly faster, must be in a code block). Modern Razor uses the <partial> tag helper.