---
title: "View components"
slug: "view-components"
abstract: "Learn about the Sitecore ASP.NET Rendering SDK view components configuration and content access functionality."
---
# View components

> [!important]
> If you integrated your app before , it's using the legacy ASP.NET Core Rendering SDK, version 22 or earlier. This SDK is no longer receiving updates, so we recommend that you [upgrade to the latest version of the new](https://doc.sitecore.com/xmc/en/developers/asp-net/latest/asp-net-core-sdk/upgrade-from-v22.html) .

In ASP.NET, view components are similar to partial views but more powerful. Refer to [the Microsoft documentation on view components](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-components?view=aspnetcore-3.1) for more details.

View components are intended for rendering logic that is too complex for a partial view, such as navigation menus, login panels, search bars, and so on. Typically, view components do not use ASP.NET model binding and only access data on demand. However, the ASP.NET Rendering SDK provides a service and base component to enable binding a model to Layout Service output.

A view component consists of three files:

- The view component class
- The Razor view
- The view model class

## Configuring view components

To bind a model in your view component, you can either inherit from `Sitecore.AspNet.RenderingEngine.Mvc, BindingViewComponent` and invoke `BindView`, or inject the `Sitecore.AspNet.RenderingEngine.Binding.IViewModelBinder` service and invoke an overload of `Bind`.

You must also map the Layout Service response to the view component with the [`AddViewComponent()` extension method](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/asp-net-core-rendering-engine.html "ASP.NET Core Rendering Engine").

In the following example, `AddViewComponent("Styleguide-Layout", "StyleguideLayout")` maps the `Styleguide-Layout` response component to the `StyleguideLayoutViewComponent` view component, and `AddViewComponent(name => name.StartsWith("sc"), "OtherViewComponent")` maps all response components prefixed with `sc` to the `OtherViewComponent` view component:

```csharp
public void ConfigureServices(IServiceCollection services)
{
  var renderingEngineBuilder = services.AddSitecoreRenderingEngine(options =>
    options
      .AddViewComponent("Styleguide-Layout", "StyleguideLayout")
      .AddViewComponent(name => name.StartsWith("sc"), "Other")
  );
}

```