Sitecore ASP.NET Core SDK
The open-source ASP.NET Core SDK lets developers integrate Sitecore XM Cloud content into their ASP.NET Core applications.
The ASP.NET Core SDK connects front-end web appsfront-end web apps built with ASP.NET Core to XM CloudXM Cloud. The SDK retrieves layout datalayout data in JSON format, which is then used to display XM Cloud content to the app's visitors. This means that the web app uses Sitecore as a headless content management system (CMS). For more information, see Architecture.
If you don't have an ASP.NET Core app, create one based on the XM Cloud ASP.NET Core Starter Kit.
To render Sitecore content in JavaScript or TypeScript web apps instead, use the Sitecore JavaScript Rendering SDK (JSS).
Development tasks with the ASP.NET Core SDK
The most common development task you'll perform with the ASP.NET Core SDK is to build model-bound views with a Sitecore data source. In this task, you build templates in the Content Editor for a Sitecore data source, then use the ASP.NET Core SDK to build views and models to render those templates. These views then render XM Cloud content to your site visitors.
Other development tasks you can perform with the ASP.NET Core SDK include:
-
Build view components - use view components to render custom logic where you access third-party data sources.
-
Build partial views - use partial views for lightweight components on a Sitecore page that don't contain their own content, such as structural components that only contain placeholders.
-
Generate a sitemap.
-
Configure redirects.
-
Configure localization and content translation, and build a language switcher.
When to choose the ASP.NET Core SDK
The ASP.NET Core SDK is for development teams who want to build ASP.NET Core web applications and have working knowledge of C# and the Model-View-Controller (MVC) architectural pattern. Knowledge of Razor views, tag helpers, and content modelling in XM Cloud is an advantage.
We recommend that development teams who want to build single-page applications (SPA) or have working knowledge of JavaScript or TypeScript use the Sitecore JavaScript Rendering SDK (JSS) instead.
Benefits of the ASP.NET Core SDK
The ASP.NET Core SDK greatly simplifies developing ASP.NET Core apps connected to XM Cloud. For example, the SDK:
-
Works seamlessly with the ASP.NET Core framework: it supports model binding, view components, partial views, Razor views, service registration, and middleware.
-
Simplifies deserializing the complex, often deeply nested layout data.
-
Contains tag helpers for rendering Sitecore fields.
-
Contains middleware that maps incoming HTTP requests to Sitecore Experience EdgeSitecore Experience Edge requests.
-
Includes hot reloading, which enables faster debugging and iteration cycles.