Develop with .NET Core
Overview
In Sitefinity CMS, you can easily build a page using drag-and-drop of widgets. These widgets and their configurations are stored in the database as a meta model. Sitefinity ASP.NET Renderer takes advantage of this model and consumes it via REST services, parses it, and constructs a page for the specific set of widgets on the page. It then renders the page in HTML and returns it to the user.
RestSDK
The .NET Core Renderer version comes with a C# RestSdk that can work with Sitefinity CMS content. You can use the REST SDK for both retrieving and creating content.
It is delivered in the Progress.Sitefinity.RestSdk
, which is automatically installed and referenced.
For more infromation, see Sitefinity GitHub repository » RestSdk.
Widgets
The standard approach to extending Sitefinity CMS frontend is to write custom widgets or to override the logic of the built-in ones. The corresponding elements for widgets in ASP.NET Core are ViewComponents
. Thus, widgets that are available in the Sitefinity CMS Toolbox, correspond to the ViewComponents
classes in the ASP.NET Core application.
The ViewComponents
Code
are useful in this scenario as they have a single method InvokeAsync
that can render multiple views and can accept a range of arguments for configuration. This is similar to the existing Sitefinity ASP.NET MVC development model, where you create a Controller
that has an Index
action that can be invoked when the widget is rendered.
However, unlike the MVC Controllers, the ViewComponents
do not have a POST
action to handle POST
requests.
Use the following video as a guideline for creating widgets:
Layout files
The ASP.NET Core pages are based on templates that are stored in the Renderer application. The ASP.NET Core templates are MVC Layout files, stored on the file system. If a page is based on one of these layout files, the Renderer will be able to render the page.
To create a base layout for all of your pages, you can leverage the power of Layout in ASP.NET Core. The layout files that are located in the Renderer’s Views
/Shared
folder are scanned and displayed in the template selector when you create a new page. However, not all of the layout files are listed there. They are filtered by their name and only the ones that contain the words Template or Layout are displayed.
NOTE: Every layout file must have a section named Scripts
.
Out-of-the-box Sitefinity ASP.NET Core Renderer comes with a blank template called Default that you can select the template selector. This layout file references Bootstrap5 CSS framework. The default Section widget templates also contain the Bootstrap5 grid system markup.
Use the following video as a guideline for creating layout files:
Application file structure
When you create your widgets and layout files, you place them in folders under your project's root folder. We recommend having a structure similar to the following:
Styles
In most cases, your website requires uniform styling. Therefore, we recommend using minified styles. Reference them in your layout files and follow the good practices for working with styles. This way, the styles are applied to all widgets on your page. The default layout file that comes with Sitefinity .NET Core Renderer references the Bootstrap 5 framework.
Scripts
You can reference your scripts on global level in the layout files or inside the widget views.
Client side development
Client-side development is performed in the same way as in any ASP.NET Core application. The developers are free to use preprocessors and build tools of their choice. Client-side development is not Sitefinity-related.
Limitations
- You cannot edit templates using Sitefinity ASP.NET Core Renderer.
- You cannot inherit templates.