Skip to content
Kentico Kontent Boilerplate for development of ASP.NET Core MVC applications.
C# HTML Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update CODEOWNERS Jun 27, 2019
.vscode Renaming Kontent. Sep 24, 2019
img upgraded packaging Nov 8, 2019
src KCL-2975 Minor review changes Nov 28, 2019
.gitignore vscode files Jun 8, 2018 Add/update issue, PR templates, code of conduct, contributing guide Sep 6, 2018 Renaming Kontent. Sep 24, 2019
Kentico.Kontent.Boilerplate.sln upgraded packaging Nov 8, 2019
LICENSE Update & expiration time Nov 25, 2019

Kentico Kontent Boilerplate for ASP.NET Core MVC

Boilerplate screenshot Build status NuGet Stack Overflow

This boilerplate includes a set of features and best practices to kick off your website development with Kentico Kontent smoothly.

What's included

Quick start



  • .NET Core 3 You can check your .NET Core version via dotnet --version.

Optional: The most seamless way to get all prerequisities is to install

Installation from NuGet

  1. Open Developer Command Prompt
  2. Run dotnet new --install "Kentico.Kontent.Boilerplate::*" to install the boilerplate to your machine
  3. Wait for the command to finish (it may take a minute or two)
  4. Run dotnet new kentico-kontent-mvc --name "MyWebsite" [-pid|project-id "<projectid>"] [-d|domain "<domain_name>"] [--output "<path>"].
  5. Open in the IDE of your choice and Run

Installation from source

  1. git clone
  2. dotnet build
  3. dotnet new -i artifacts/*.nupkg

How Tos

How to debug the app

In Windows, there are basically two ways to run the app:

  • via IIS
  • as a standalone command-line app

You can read more about the differences on Rick Strahl's blog.

We recommend choosing the second option - as a standalone app. In Visual Studio, you can switch to it in the toolbar:

Debugging mode

How to change Kentico Kontent Project ID and Delivery Preview API key

Kentico Kontent Project ID is stored inside appsettings.json file. This setting is automatically loaded using Options and configuration objects. You can also provide additional environment-specific configuration in appsettings.production.json and appsettings.development.json files.

You can also set the Project ID during the template instantiation by applying the -pid|project-id parameter.

For security reasons, Delivery Preview API key should be stored outside of the project tree. It's recommended to use Secret Manager to store sensitive data.

How to generate Strongly Typed Models for Content Types

With the new Delivery SDK, you can take advantage of code-first approach. To do that you have to instruct the SDK to use strongly-typed models. These models can be generated automatically by model generator utility. By convention, all Content Type Models are stored within the Models/ContentTypes folder. All generated classes are marked as partial which means that they can be extended in separate files. This should prevent losing custom code in case the models get regenerated. When generating models, be sure to set the -n command line parameter to [project namespace].Models.

If you want to use Display Templates (MVC), make sure you generate also a custom type provider (add the --withtypeprovider parameter when running the generator utility).

You can regenerate the models using the included PowerShell script that utilizes the model generator utility. The script is located at Tools/GenerateModels.ps1.

How to resolve links

Rich text elements in Kentico Kontent can contain links to other content items. It's up to a developer to decide how the links should be represented on a live site. Resolution logic can be adjusted in the CustomContentLinkUrlResolver. See the documentation for detailed info.

How to set up webhook-enabled caching

All content retrieved from Kentico Kontent is by default cached for 10 minutes in a MemoryCache singleton object. When content is stale (newer version exists) it is cached for 2 seconds. You can change the expiration times in Startup.

If displaying outdated content for a limited time is not an option, you need to use another caching strategy and invalidate cached content when a webhook notification about content change is received. To enable this caching strategy just switch to another caching client by using IServiceCollection.AddWebhookInvalidatedCachingClient extension in Startup.

Also, you need to create a webhook. When entering a webhook URL, append a /Webhooks/Webhooks path to a publicly available URL address of the application, e.g. Finally, copy the API secret and put it into the app settings (usually the appsettings.json) as the KenticoKontentWebhookSecret environment variable.

New webhook configuration

Note: During local development, you can use the ngrok service to route to your workstation. Simply start your application locally and run command ngrok http [port] localhost:[port] and set the webhook URL to the displayed HTTPS address.

Note: Speed of the Delivery/Preview API service is already tuned up because the service uses a geo-distributed CDN network for most of the types of requests. Therefore, the main advantage of caching in Kentico Kontent applications is not speed but lowering the amount of requests needed (See pricing for details).

How to resize images based on window width

The boilerplate contains a sample implementation of the HtmlHelperExtensions. Using the AssetImage() extension method, you can easily create an img tag with srcset and sizes attributes.

How to adjust the sitemap.xml

The boilerplate contains a sample implementation of the SiteMapController. Make sure you specify desired content types in the Index() action method. Also, you can adjust the URL resolution logic in the GetPageUrl() method.

How to handle 404 errors or any other error

Error handling is setup by default. Any server exception or error response within 400-600 status code range is handled by ErrorController. By default, it's configured to display Not Found error page for 404 error and General Error for anything else.

How to adjust URL rewriting

The Boilerplate is configured to load all URL Rewriting rules from IISUrlRewrite.xml file. Add or modify existing rules to match your expected behavior. This is a good way to set up 301 Permanent redirects or www<->non-www redirects.

You can adjust the domain name in the default rewriting rules during the template instantiation by applying the -d|domain parameter.

Feedback & Contributing

Any feedback is much appreciated. Check out the contributing to see the best places to file issues, start discussions and begin contributing.

Wall of Fame

We would like to express our thanks to the following people who contributed and made the project possible:

Would you like to become a hero too? Pick an issue and send us a pull request!


You can’t perform that action at this time.