Kontent.Ai.AspNetCore
0.14.1
dotnet add package Kontent.Ai.AspNetCore --version 0.14.1
NuGet\Install-Package Kontent.Ai.AspNetCore -Version 0.14.1
<PackageReference Include="Kontent.Ai.AspNetCore" Version="0.14.1" />
paket add Kontent.Ai.AspNetCore --version 0.14.1
#r "nuget: Kontent.Ai.AspNetCore, 0.14.1"
// Install Kontent.Ai.AspNetCore as a Cake Addin #addin nuget:?package=Kontent.Ai.AspNetCore&version=0.14.1 // Install Kontent.Ai.AspNetCore as a Cake Tool #tool nuget:?package=Kontent.Ai.AspNetCore&version=0.14.1
ASP.NET Core extensions for Kontent.ai apps
Tag Helpers
img-asset
tag helper
Useful for rendering responsive images. Supports Assets and Inline images in rich-text elements.
appsettings.json
:
...
"ImageTransformationOptions": {
"ResponsiveWidths": [ 200, 300, 400, 600, 800, 1000, 1200, 1400, 1600, 2000 ]
}
...
\_ViewImports.cshtml
:
@addTagHelper *, Kontent.Ai.AspNetCore
Startup.cs
:
public void ConfigureServices(IServiceCollection services)
{
// Adds services required for using options.
services.AddOptions();
// Register the ImageTransformationOptions required by Kontent.ai tag helpers
services.Configure<ImageTransformationOptions>(Configuration.GetSection(nameof(ImageTransformationOptions)));
}
View.cshtml
:
<img-asset asset="@Model.TeaserImage.First()" class="img-responsive" default-width="300">
<media-condition min-width="769" image-width="300" />
<media-condition min-width="330" max-width="768" image-width="689" />
</img-asset>
Output
<img
class="img-responsive"
alt="Coffee Brewing Techniques"
sizes="(min-width: 769px) 300px, (max-width: 768px) and (min-width: 330px) 689px, 300px"
src="https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=2000"
srcset="
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=200 200w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=300 300w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=400 400w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=600 600w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=800 800w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=1000 1000w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=1200 1200w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=1400 1400w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=1600 1600w,
https://assets-us-01.kc-usercontent.com/975bf280-fd91-488c-994c-2f04416e5ee3/fcbb12e6-66a3-4672-85d9-d502d16b8d9c/which-brewing-fits-you-1080px.jpg?w=2000 2000w
"
title="Coffee Brewing Techniques"
/>
Webhooks
Package provides a model for webhook deserialization: WebhookNotification
. Legacy webhooks are supported via classes DeliveryWebhookModel
and ManagementWebhookModel
, to be used with legacy (preview) delivery API and management API triggers respectively. See Webhooks reference in Kontent.ai documentation.
Middlewares
Webhook signature verification middleware
This middleware verifies the X-Kontent-ai-Signature
(and the legacy X-KC-Signature
) header. Returns 401 response if the signature is invalid.
appsettings.json
:
...
"WebhookOptions": {
"Secret": "<your_secret>"
},
...
Startup.cs
:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// Register the validation middleware for any number of controllers that serve for processing webhooks
app.UseWebhookSignatureValidator(context => context.Request.Path.StartsWithSegments("/webhooks/webhooks", StringComparison.OrdinalIgnoreCase), Configuration.GetSection(nameof(WebhookOptions)));
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Kontent.Ai.Delivery.Abstractions (>= 17.0.0)
- Kontent.Ai.Urls (>= 17.0.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Options (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.14.1 | 1,654 | 5/13/2024 |
0.14.0 | 305 | 4/4/2024 |
0.13.1 | 18,267 | 8/3/2022 |
0.13.0 | 135 | 8/3/2022 |
0.13.0-beta.1 | 126 | 8/2/2022 |