Fusonic.Extensions.AspNetCore
11.0.0
Prefix Reserved
dotnet add package Fusonic.Extensions.AspNetCore --version 11.0.0
NuGet\Install-Package Fusonic.Extensions.AspNetCore -Version 11.0.0
<PackageReference Include="Fusonic.Extensions.AspNetCore" Version="11.0.0" />
<PackageVersion Include="Fusonic.Extensions.AspNetCore" Version="11.0.0" />
<PackageReference Include="Fusonic.Extensions.AspNetCore" />
paket add Fusonic.Extensions.AspNetCore --version 11.0.0
#r "nuget: Fusonic.Extensions.AspNetCore, 11.0.0"
#:package Fusonic.Extensions.AspNetCore@11.0.0
#addin nuget:?package=Fusonic.Extensions.AspNetCore&version=11.0.0
#tool nuget:?package=Fusonic.Extensions.AspNetCore&version=11.0.0
ASP .Net Core Extensions
Package: Fusonic.Extensions.AspNetCore
The package references SimpleInjector and Scrutor with PrivateAssets="all". If you use the SimpleInjector or Scrutor based registrations below, reference SimpleInjector or Scrutor in your own project.
ServiceCollection extensions
Namespace: Fusonic.Extensions.AspNetCore
services.AddAll<T>(IEnumerable<Assembly> assemblies, ServiceLifetime lifetime = ServiceLifetime.Scoped) registers all non-abstract classes implementing T in the given assemblies. T must be an interface, otherwise an ArgumentException is thrown.
CultureUtil
Namespace: Fusonic.Extensions.AspNetCore.Http
The culture util provides a simple way to get the culture from a user based on a list of supported cultures. It supports a "fallback-to-child", meaning if your application supports "de-AT" and the user only supports "de-DE", the util returns "de-AT" as the best common language.
Example settings:
public class AppSettings
{
public CultureInfo DefaultCulture { get; set; } = null!;
public CultureInfo[] SupportedCultures { get; set; } = null!;
}
Usage:
// Supported Cultures: de-AT,en-GB
// Default: de-AT
// Header: de-AT,en-US Result: de-AT (match)
// Header: fr-FR,en-GB Result: en-GB (match)
// Header: de-DE,en-US Result: de-AT (first common language)
// Header: fr-FR,en-US Result: en-GB (first common language)
// Header: fr-FR Result: de-AT (no match, default)
var culture = CultureUtil.FromAcceptLanguageHeader(HttpContext, appSettings.SupportedCultures, appSettings.DefaultCulture);
Weights (q=) in the header are respected. An overload takes the parsed header (IList<StringWithQualityHeaderValue>) instead of the HttpContext. CultureUtil.GetFirstSupportedCulture(string culture, IEnumerable<CultureInfo> supportedCultures, CultureInfo? defaultCulture = null) applies the same fallback to a single culture name.
Ignore paths Middleware
Namespace: Fusonic.Extensions.AspNetCore.Http
Returns 404 for all configured paths.
This is useful if you, for example, want to avoid a SPA to handle a path. A typo in an API-Url should result in 404 and should not be handled by the SPA.
Usage:
// For example right before the SPA
app.UseIgnorePaths("/api", "/swagger", "/hangfire");
An overload takes an IEnumerable<PathString>.
Cache headers Middleware
Namespace: Fusonic.Extensions.AspNetCore.Http (options in Fusonic.Extensions.AspNetCore.Http.Middlewares)
Sets the Cache-Control header per route prefix. It only sets the header if the response doesn't have one yet. The first matching route wins; if none matches, DefaultHeader is used.
using Microsoft.Net.Http.Headers;
app.UseCacheHeaders(options =>
{
options.ConfigureNoCacheForRoutes(["/api"]);
options.ConfigureValueForRoutes(new CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(30) }, ["/assets"]);
options.DefaultHeader = new CacheControlHeaderValue { NoCache = true };
});
HttpContextUserAccessor
Namespace: Fusonic.Extensions.AspNetCore.Http
Implementation of IUserAccessor (from Fusonic.Extensions.Common) that returns the user of the current HttpContext. It is required e.g. by the out-of-band processing of Fusonic.Extensions.Hangfire.
// Microsoft.Extensions.DependencyInjection
services.AddHttpContextAccessor();
services.AddScoped<IUserAccessor, HttpContextUserAccessor>();
// SimpleInjector (IHttpContextAccessor must be cross-wired from the IServiceCollection)
services.AddHttpContextAccessor();
container.Register<IUserAccessor, HttpContextUserAccessor>();
User throws an InvalidOperationException if there is no HttpContext; use TryGetUser for a non-throwing variant.
Validation of Mediator requests
Namespace: Fusonic.Extensions.AspNetCore.Validation
Mediator requests can be validated with a simple decorator. Internally it uses the same validator that is used by ASP.NET Core for the request validation (IObjectModelValidator). This validator is registered by services.AddControllers() / services.AddMvc(). With SimpleInjector it must be resolvable from the container: services.AddSimpleInjector(container, ...) cross-wires framework components like this one automatically.
To enable Mediator request validation, add the decorator RequestValidationDecorator to IRequestHandler:
// SimpleInjector
container.RegisterDecorator(typeof(IRequestHandler<,>), typeof(RequestValidationDecorator<,>));
// Microsoft.Extensions.DependencyInjection with Scrutor
// Register your handlers first, as Scrutor only decorates already registered services.
services.Decorate(typeof(IRequestHandler<,>), typeof(RequestValidationDecorator<,>));
When using the out-of-band decorators of Fusonic.Extensions.Hangfire, register them before this decorator (RegisterOutOfBandDecorators() / AddOutOfBandDecorators()).
You can then use the System.ComponentModel.DataAnnotations-attributes and the IValidatableObject-interface for validating your models. When model validation fails, a RequestValidationException gets thrown. Its Errors property (IDictionary<string, List<string>>, property name to error messages) and RequestType contain the details. You might want to handle it in your Exception filter, if you have one.
Example:
public class GetSomething : IQuery<IReadOnlyList<string>>, IValidatableObject
{
[Required]
public string Search { get; set; } = null!;
[Range(1, 100)]
public int MaxResults { get; set; } = 10;
public DateTime From { get; set; }
public DateTime To { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (From >= To)
yield return new ValidationResult("From must be before To.", [nameof(From), nameof(To)]);
}
}
This also works with records.
OpenTelemetry
Namespace: Fusonic.Extensions.AspNetCore.OpenTelemetry
Mediator tracing
To trace every request and notification sent by the Mediator package, register the tracing decorators:
// SimpleInjector: register the tracing decorators before the mediator.
container.RegisterMediatorTracingDecorators();
container.RegisterMediator( /* Mediator configuration */ );
// Microsoft.Extensions.DependencyInjection with Scrutor: register your handlers first,
// as Scrutor only decorates already registered services.
services.AddMediatorTracingDecorators();
When using the out-of-band decorators of Fusonic.Extensions.Hangfire, register them before the tracing decorators (RegisterOutOfBandDecorators() / AddOutOfBandDecorators()).
AddMediatorTracingDecorators uses TryDecorate: if no handlers are registered yet, it silently does nothing. See the Mediator documentation for how to register the handlers.
Also, when configuring the OpenTelemetry tracer, you need to enable the instrumentation:
services.AddOpenTelemetry()
.WithTracing(tracer => tracer.AddMediatorInstrumentation());
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fusonic.Extensions.Common (>= 11.0.0)
- Fusonic.Extensions.Mediator (>= 11.0.0)
- OpenTelemetry.Api (>= 1.21.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Fusonic.Extensions.AspNetCore:
| Package | Downloads |
|---|---|
|
Fusonic.Extensions.Email
Contains common functionality for rendering email templates using razor engine and sending emails via MailKit. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0 | 0 | 11/23/2026 |
| 10.3.0 | 190 | 11/9/2026 |
| 10.2.0 | 206 | 11/5/2026 |
| 10.1.0 | 3,622 | 3/18/2026 |
| 10.0.1 | 172 | 3/17/2026 |
| 10.0.0 | 1,087 | 11/25/2025 |
| 10.0.0-rc.2 | 217 | 11/24/2025 |
| 10.0.0-rc.1 | 185 | 9/12/2025 |
| 9.5.4 | 729 | 8/20/2025 |
| 9.5.3 | 620 | 3/28/2025 |
| 9.5.2 | 871 | 1/16/2025 |
| 9.5.0 | 411 | 10/4/2024 |
| 9.4.0 | 501 | 9/23/2024 |
| 9.3.1 | 420 | 9/11/2024 |
| 9.3.0 | 326 | 9/11/2024 |
| 9.2.0 | 339 | 8/8/2024 |
| 9.2.0-rc.3 | 151 | 8/7/2024 |
| 9.2.0-rc.2 | 137 | 8/5/2024 |
| 9.2.0-rc.1 | 140 | 8/1/2024 |
| 9.1.0 | 309 | 7/29/2024 |