Paradigm | Package | Downloads | Compatibility | Documentation |
---|---|---|---|---|
Async | netstandard2.0 |
📖 | ||
Reactive | netstandard2.0 |
📖 |
The Kentico Kontent Delivery .NET SDK is a client library that lets you easily retrieve content from Kentico Kontent.
Installation via Package Manager Console in Visual Studio:
PM> Install-Package Kentico.Kontent.Delivery
Installation via .NET CLI:
> dotnet add package Kentico.Kontent.Delivery
To retrieve content from your Kentico Kontent projects, you'll be using an implementation of the IDeliveryClient
interface. This is the main interface of the SDK. Here's how you can instantiate and use the Delivery client either with DI/IoC or without DI/IoC.
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDeliveryClient(Configuration);
}
HomeController.cs
public class HomeController
{
private IDeliveryClient _client;
public HomeController(IDeliveryClient deliveryClient)
{
_client = deliveryClient;
}
}
In this case, the SDK reads the configuration from the DeliveryOptions
section of the Configuration
object. There are many ways of providing the configuration to the DeliveryClient
as well as many advanced registration scenarios which you can all find in the Wiki.
To see a complete working example, go to one of our sample apps:
To spin up a fully configured blank site quickly, use the:
You can also set up a DeliveryOptions
manually using the DeliveryClientBuilder
.
IDeliveryClient _client = DeliveryClientBuilder
.WithOptions(builder => builder
.WithProjectId("<YOUR_PROJECT_ID>")
.UseProductionApi()
.Build())
.Build();
Use the .NET code generator to generate POCO models:
public class Article
{
public string Title { get; set; }
public string Summary { get; set; }
public string Body { get; set; }
public DateTime? PostDate { get; set; }
public ContentItemSystemAttributes System { get; set; }
}
Call the IDeliveryClient
to retrieve data from Kentico Kontent:
// Retrieving a single content item
var response = await _client.GetItemAsync<Article>("<article_codename>");
var title = response.Item.Title; // -> "On Roasts"
var lang = response.Item.System.Language; // -> "en-US"
See Working with Strongly Typed Models to learn how to generate models and adjust the logic to your needs.
For more developer resources, visit:
- ✔️ Best practices for Delivery SDK for .NET
- Kentico Kontent Docs:
Check out the contributing page to see the best places to file issues, start discussions, and begin contributing.