Zymergi.AspNetCore 11.4.0-alpha

This is a prerelease version of Zymergi.AspNetCore.
dotnet add package Zymergi.AspNetCore --version 11.4.0-alpha
                    
NuGet\Install-Package Zymergi.AspNetCore -Version 11.4.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zymergi.AspNetCore" Version="11.4.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zymergi.AspNetCore" Version="11.4.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Zymergi.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zymergi.AspNetCore --version 11.4.0-alpha
                    
#r "nuget: Zymergi.AspNetCore, 11.4.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zymergi.AspNetCore@11.4.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zymergi.AspNetCore&version=11.4.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Zymergi.AspNetCore&version=11.4.0-alpha&prerelease
                    
Install as a Cake Tool

Zymergi.AspNetCore

Shared ASP.NET Core pieces for Zymergi apps: XSLT-rendered MVC controllers (ControllerXslt), a usage-tracking action filter (TrackUsageAttribute), and small request helpers (claims, correlation id, route data, header copy, log search model).

Targets .NET 10. Depends on Zymergi.Core, Zymergi.Data, and Zymergi.Rendering. Article and social controllers are not in this package.

Install

dotnet add package Zymergi.AspNetCore

Register in Program.cs

using Zymergi.AspNetCore;
using Zymergi.AspNetCore.Diagnostics;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllersWithViews();
builder.Services.AddHttpContextAccessor();
builder.Services.AddXslTransformViewPool(builder.Configuration);       // singleton pool; reads PATH_XSL
builder.Services.AddTrackUsage(o => o.RedactRouteData = true);          // options for TrackUsageAttribute
builder.Services.AddProblemDetails();

var app = builder.Build();
app.UseExceptionHandler();
app.UseStatusCodePages();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();

PATH_XSL is a folder relative to the current directory. A missing key throws when the pool is first resolved.

Use it

XSLT page controller. The pool key is the stylesheet file name without .xsl:

using Microsoft.AspNetCore.Mvc;
using Zymergi.AspNetCore.Diagnostics;
using Zymergi.AspNetCore.Mvc.Controllers;
using Zymergi.Rendering.XslTransformView;

public sealed class PagesController(IHttpContextAccessor ctx, IConfiguration config, IXslTransformViewPool xsl, PageService pages)
    : ControllerXslt(ctx, config, xsl)
{
    [HttpGet("/pages/{slug}")]
    [TrackUsage("view page", "PagesController.Show")]
    public async Task<IActionResult> Show(string slug, CancellationToken ct)
    {
        string? xml = await pages.GetXmlAsync(slug, ct);
        if (xml is null) return NotFound();
        return Content(xsl["page"].Transform(xml, _xsltArgs), "text/html");
    }
}

Reading claims in a minimal API:

using System.Security.Claims;
using Zymergi.AspNetCore;
using Zymergi.AspNetCore.Logging;

app.MapGet("/me", (ClaimsPrincipal user, HttpContext http) => new
{
    Email = user.Claims.GetValue("email"),
    CorrelationId = http.GetCorrelationId(),
}).RequireAuthorization();

Best practices

  • Authenticate with the standard handlers (AddAuthentication().AddJwtBearer(...) or cookies plus OpenID Connect) and protect endpoints with RequireAuthorization or [Authorize]. Read claims from HttpContext.User, which the handler has validated. Do not parse a JWT yourself.
  • Errors: AddProblemDetails plus UseExceptionHandler, with an IExceptionHandler for domain errors. Do not return stack traces.
  • Inject services with the right lifetime: options and stateless helpers as singletons, data access through a singleton IDbConnectionFactory (see Zymergi.Data), per-request state as scoped. Never inject a scoped service into a singleton.
  • Bind settings with IOptions<T> and ValidateOnStart.
  • Log with ILogger<T> and message templates. TrackUsageAttribute logs one information entry per action through ILogger<TrackUsageFilter>; set RedactRouteData when route values can hold personal data.
  • Pass CancellationToken (or HttpContext.RequestAborted) to every async call.
  • Use output caching (AddOutputCache, [OutputCache]) for public XSLT pages and HybridCache for expensive data; use rate limiting (AddRateLimiter) on public endpoints.
  • DefaultXsltArgsProvider passes only id_name, id_picture, and id_emailaddress claims to stylesheets, and HTML-encodes the Referer. Implement IXsltArgsProvider to pass more. Never use disable-output-escaping on request values.

Testing

  • Use WebApplicationFactory<Program> (Microsoft.AspNetCore.Mvc.Testing) for endpoint tests, and replace data and search services with fakes in ConfigureTestServices.
  • Test a controller action directly by constructing it with fakes (IXslTransformViewPool, IHttpContextAccessor).
  • Point PATH_XSL at a test folder of stylesheets.

Gotchas

  • Zymergi.AspNetCore and Zymergi.Rendering both define AddXslTransformViewPool(IServiceCollection, IConfiguration). With both namespaces imported in one file, the call is ambiguous (CS0121). Import only one, or call Zymergi.Rendering.ServiceCollectionExtensions.AddXslTransformViewPool(builder.Services, builder.Configuration).
  • GetCorrelationId is in namespace Zymergi.AspNetCore.Logging, which also holds the obsolete TrackUsageAttribute. Importing both Zymergi.AspNetCore.Logging and Zymergi.AspNetCore.Diagnostics in one file makes [TrackUsage] ambiguous (CS0104). Call Zymergi.AspNetCore.Logging.ExtensionMethods.GetCorrelationId(http) instead of importing the namespace.
  • An unknown stylesheet key returns an empty view, not an exception.
  • Obsolete, removed in 12.0: DbRegistrableControllerBase<T>, CachedHttpClient, CachedServiceBase, ClaimsList (no signature check), TrackPerformanceFilter, Zymergi.AspNetCore.Logging.TrackUsageAttribute, WebLoggor, WebExtensionMethods, RefreshablePersistedAuthProperties, and RepeatController. Replacements: your own controllers, IHttpClientFactory plus HybridCache, the JWT bearer handler, ILogger<T>, and Zymergi.AspNetCore.Diagnostics.TrackUsageAttribute.
  • HttpClient.CopyHeaders changes the client's default headers. Use the HttpRequestMessage.CopyHeaders overload for per-request headers.

Version notes

11.4.0-alpha: no API change. The README no longer shows ClaimsList.

11.3.0-alpha

  • DefaultXsltArgsProvider passes fewer claims, encodes the Referer, and sets dtNow to local time.
  • The obsolete DbRegistrableControllerBase<T>.Remove and WebLoggor.PersistLogEntryToRepoAsync throw InvalidOperationException.

Source: bitbucket.org/zymergy/zymergi.saas

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.4.0-alpha 95 11/16/2026
11.3.0-alpha 68 11/12/2026
11.2.0-alpha 62 11/2/2026
11.1.1-alpha 99 10/4/2026
11.1.0-alpha 108 10/1/2026
11.0.6-alpha 122 7/10/2026
11.0.5-alpha 129 7/9/2026
11.0.4-alpha 91 7/6/2026
11.0.3-alpha 81 7/6/2026
11.0.2-alpha 129 6/30/2026
11.0.1-alpha 123 6/30/2026
11.0.0-alpha 83 6/30/2026