https://github.com/kontent-ai/aspnetcore-extensions
ASP.NET Core extensions for Kontent.ai apps.
https://github.com/kontent-ai/aspnetcore-extensions
asp-net kontent-ai kontent-ai-tool middleware middlewares tag-helper tag-helpers
Last synced: about 1 month ago
JSON representation
ASP.NET Core extensions for Kontent.ai apps.
- Host: GitHub
- URL: https://github.com/kontent-ai/aspnetcore-extensions
- Owner: kontent-ai
- License: mit
- Created: 2020-03-13T11:18:17.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T12:48:14.000Z (about 1 year ago)
- Last Synced: 2025-04-21T14:19:29.411Z (about 2 months ago)
- Topics: asp-net, kontent-ai, kontent-ai-tool, middleware, middlewares, tag-helper, tag-helpers
- Language: C#
- Homepage: https://www.nuget.org/packages/Kontent.Ai.AspNetCore
- Size: 133 KB
- Stars: 2
- Watchers: 16
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# ASP.NET Core extensions for Kontent.ai apps
[](https://www.nuget.org/packages/Kontent.Ai.AspNetCore/)
[](https://www.nuget.org/packages/Kontent.Ai.AspNetCore/)
[](https://github.com/aspnetcore/actions/workflows/integrate.yml)
[](https://codecov.io/gh/kontent-ai/aspnetcore)
[](https://stackoverflow.com/tags/kontent-ai)
[](https://discord.gg/SKCxwPtevJ)## Tag Helpers
### `img-asset` tag helper
Useful for rendering responsive images. Supports Assets and Inline images in rich-text elements.
`appsettings.json`:
```json
...
"ImageTransformationOptions": {
"ResponsiveWidths": [ 200, 300, 400, 600, 800, 1000, 1200, 1400, 1600, 2000 ]
}
...
````\_ViewImports.cshtml`:
```razor
@addTagHelper *, Kontent.Ai.AspNetCore
````Startup.cs`:
```csharp
public void ConfigureServices(IServiceCollection services)
{
// Adds services required for using options.
services.AddOptions();// Register the ImageTransformationOptions required by Kontent.ai tag helpers
services.Configure(Configuration.GetSection(nameof(ImageTransformationOptions)));
}
````View.cshtml`:
```razor
```
#### Output
```html
![]()
```## 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](https://kontent.ai/learn/reference/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`:
```json
...
"WebhookOptions": {
"Secret": ""
},
...
````Startup.cs`:
```csharp
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)));
}
```