{"id":19924370,"url":"https://github.com/kontent-ai/boilerplate-net","last_synced_at":"2025-05-03T07:31:25.743Z","repository":{"id":44619906,"uuid":"81316363","full_name":"kontent-ai/boilerplate-net","owner":"kontent-ai","description":"Kontent.ai Boilerplate for development of ASP.NET Core MVC applications.","archived":false,"fork":false,"pushed_at":"2023-08-01T15:41:08.000Z","size":3280,"stargazers_count":32,"open_issues_count":5,"forks_count":35,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-07T12:49:02.746Z","etag":null,"topics":["asp-net-core","aspnet-core","boilerplate","hacktoberfest","kontent-ai","mvc","net6","visual-studio"],"latest_commit_sha":null,"homepage":"https://kontent.ai/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kontent-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-08T10:13:23.000Z","updated_at":"2024-08-25T15:02:50.000Z","dependencies_parsed_at":"2024-06-21T15:20:35.436Z","dependency_job_id":"7524385f-d9fd-4177-955f-ddd6142026e7","html_url":"https://github.com/kontent-ai/boilerplate-net","commit_stats":null,"previous_names":["kontent-ai/kontent-boilerplate-net","kentico/kontent-boilerplate-net","kentico/cloud-boilerplate-net"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fboilerplate-net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fboilerplate-net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fboilerplate-net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fboilerplate-net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kontent-ai","download_url":"https://codeload.github.com/kontent-ai/boilerplate-net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252156899,"owners_count":21703371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","aspnet-core","boilerplate","hacktoberfest","kontent-ai","mvc","net6","visual-studio"],"created_at":"2024-11-12T22:17:10.763Z","updated_at":"2025-05-03T07:31:20.727Z","avatar_url":"https://github.com/kontent-ai.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kontent.ai Boilerplate for ASP.NET Core MVC\n\n[![Build \u0026 Test](https://github.com/kontent-ai/boilerplate-net/actions/workflows/integrate.yml/badge.svg)](https://github.com/kontent-ai/boilerplate-net/actions/workflows/integrate.yml)\n[![codecov](https://codecov.io/gh/kontent-ai/boilerplate-net/branch/master/graph/badge.svg?token=DThPm8Jowt)](https://codecov.io/gh/kontent-ai/boilerplate-net)\n[![Stack Overflow](https://img.shields.io/badge/Stack%20Overflow-ASK%20NOW-FE7A16.svg?logo=stackoverflow\u0026logoColor=white)](https://stackoverflow.com/tags/kontent-ai)\n[![Discord](https://img.shields.io/discord/821885171984891914?color=%237289DA\u0026label=Kontent.ai%20Discord\u0026logo=discord)](https://discord.gg/SKCxwPtevJ)\n\n|                                                            Package                                                            |                                                           Downloads                                                           |                        Compatibility                         |\n| :---------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------: |\n| [![NuGet](https://img.shields.io/nuget/v/Kontent.Ai.Boilerplate.svg)](https://www.nuget.org/packages/Kontent.Ai.Boilerplate/) | [![NuGet](https://img.shields.io/nuget/dt/Kontent.Ai.Boilerplate.svg)](https://www.nuget.org/packages/Kontent.Ai.Boilerplate) | [`net6.0`](https://dotnet.microsoft.com/download/dotnet/6.0) |\n\nThis boilerplate lets you easily scaffold a web project for development with Kontent.ai and give you a head start in a successful web project. It includes a set of pre-configured features and demonstrates best practices in order to kick off your website development with Kontent.ai smoothly.\n\n## What's included\n\n[\u003cimg align=\"right\" src=\"./img/template_thumbnail.png\" alt=\"Boilerplate screenshot\" /\u003e](./img/template.png)\n\n- [Kontent.ai Delivery SDK](https://github.com/kontent-ai/delivery-sdk-net)\n  - [Sample link resolver](#how-to-resolve-links)\n- [Pre-build event for model generating](#how-to-generate-strongly-typed-models-for-content-types)\n- [Webhook-enabed caching](#how-to-set-up-webhook-enabled-caching)\n- [HTTP Status codes handling (404, 500, ...)](#how-to-handle-404-errors-or-any-other-error)\n- [Adjustable images](#how-to-render-responsive-images)\n- [Sitemap.xml](#how-to-adjust-the-sitemapxml) generator\n- [URL Rewriting examples](#how-to-adjust-url-rewriting)\n  - 301 URL Rewriting\n  - www -\u003e non-www redirection\n- Configs for Dev and Production environment\n- robots.txt\n- Logging\n- Unit tests ([xUnit](https://xunit.net/))\n\n## Getting started\n\n### Installation from NuGet\n\n1. Run `dotnet new --install \"Kontent.Ai.Boilerplate::*\"` to install the boilerplate to your machine\n2. Run `dotnet new kontent-ai-mvc --name \"MyWebsite\" [-pid|project-id \"\u003cprojectid\u003e\"] [-d|domain \"\u003cdomain_name\u003e\"] [--output \"\u003cpath\u003e\"]` to init a website from the template\n   - You can change the project ID later at any time in `appsettings.json`\n3. Open in the IDE of your choice and Run\n\n_Note: You can [install the template from the sourcecode](../../wiki/Installation-from-source) too._\n\n## How Tos\n\n### How to generate Strongly Typed Models for Content Types\n\nBy convention, all [strongly-typed Content Type models](https://github.com/kontent-ai/delivery-sdk-net/blob/master/docs/customization-and-extensibility/strongly-typed-models.md) are generated and stored within the `Models/ContentTypes` folder. All generated classes are marked as [`partial`](https://msdn.microsoft.com/en-us/library/wa80x488.aspx) to enable further customization without losing the generated code.\n\nThe generating is facilitated by a [.NET generator tool](https://github.com/kontent-ai/model-generator-net) as pre-build event. If you wish to customize the process, adjust the [`Tools/GenerateModels.ps1`](https://github.com/kontent-ai/boilerplate-net/blob/master/src/content/Kontent.Ai.Boilerplate/Tools/GenerateModels.ps1) script.\n\nFor instance, to set a different namespace, set the `-n` command line parameter to `[project namespace].Models`. Or, to enable usage of [Display Templates (MVC)](http://www.growingwiththeweb.com/2012/12/aspnet-mvc-display-and-editor-templates.html) for rich-text elements, set `--structuredmodel true`.\n\nYou can regenerate the models using the included PowerShell script that utilizes the model generator utility. The script is located at .\n\n### How to resolve links\n\nRich text elements in Kontent.ai 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`](https://github.com/kontent-ai/boilerplate-net/blob/master/src/content/Kontent.Ai.Boilerplate/Resolvers/CustomContentLinkUrlResolver.cs). See the [documentation](https://github.com/kontent-ai/delivery-sdk-net/blob/master/docs/customization-and-extensibility/rich-text/resolving-item-links.md) for detailed info.\n\n### How to set up webhook-enabled caching\n\nAll content retrieved from Kontent.ai is by default [cached](https://github.com/kontent-ai/delivery-sdk-net/blob/master/docs/retrieving-data/caching.md) for 24 minutes. When content is stale (a newer version exists) it is cached for only 2 seconds. You can change the expiration times via the `DeliveryCacheOptions` in [Startup](https://github.com/kontent-ai/boilerplate-net/blob/master/src/content/Kontent.Ai.Boilerplate/Startup.cs#L42-L47).\n\nIf you want to invalidate cache items as soon as they're updated in Kontent, you need to [create a webhook](https://kontent.ai/learn/tutorials/develop-apps/integrate/webhooks#a-create-a-webhook) and point it to the `/Webhooks/Webhooks` relative path of your application. The URL of the app needs to be publicly accessible, e.g. `https://myboilerplate.azurewebsites.net/Webhooks/Webhooks`. Finally, copy the API secret and store it as `WebhookOptions::Secret` in your `Configuration` object, typically in the [Secret Manager](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets) or [Azure Key Vault](https://docs.microsoft.com/en-us/aspnet/core/security/key-vault-configuration)\n\n![New webhook configuration](https://i.imgur.com/Zbp0UOL.png)\n\n**Note**: During local development, you can use the [ngrok](https://ngrok.com/) service to route to your workstation. Simply start your application locally and run command `.\\ngrok.exe http [port] -host-header=\"localhost:[port]\"` (e.g. `.\\ngrok.exe http 59652 -host-header=\"localhost:59652\"`) and set the webhook URL to the displayed HTTPS address.\n\n**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 Kontent.ai applications is not speed but lowering the amount of requests needed (See [pricing](https://kontent.ai/pricing) for details).\n\n### How to render responsive images\n\nThe boilerplate contains a sample implementation of the `img-asset` tag helper from the [Kontent.Ai.AspNetCore](https://www.nuget.org/packages/Kontent.Ai.AspNetCore) NuGet package. Using the `img-asset` tag helper, you can easily create an `img` tag with `srcset` and `sizes` attributes.\n\n### How to adjust the sitemap.xml\n\nThe boilerplate contains a sample implementation of the [`SiteMapController`](https://github.com/kontent-ai/boilerplate-net/blob/master/src/content/Kontent.Ai.Boilerplate/Controllers/SiteMapController.cs). Make sure you specify desired content types in the `Index()` action method. Also, you can adjust the URL resolution logic in the `GetPageUrl()` method.\n\n### How to handle 404 errors or any other error\n\nError 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.\n\n### How to adjust URL rewriting\n\nThe Boilerplate is configured to load all [URL Rewriting](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting) rules from [IISUrlRewrite.xml](/src/content/Kontent.Ai.Boilerplate/IISUrlRewrite.xml) file. Add or modify existing rules to match your expected behavior.\nThis is a good way to set up 301 Permanent redirects or www\u003c-\u003enon-www redirects.\n\nYou can adjust the domain name in the default rewriting rules during the template instantiation by applying the `-d|domain` parameter.\n\n## Get involved\n\nCheck out the [contributing](CONTRIBUTING.md) page to see the best places to file issues, start discussions, and begin contributing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontent-ai%2Fboilerplate-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkontent-ai%2Fboilerplate-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontent-ai%2Fboilerplate-net/lists"}