Fusonic.Extensions.AspNetCore
9.5.4
Prefix Reserved
dotnet add package Fusonic.Extensions.AspNetCore --version 9.5.4
NuGet\Install-Package Fusonic.Extensions.AspNetCore -Version 9.5.4
<PackageReference Include="Fusonic.Extensions.AspNetCore" Version="9.5.4" />
<PackageVersion Include="Fusonic.Extensions.AspNetCore" Version="9.5.4" />
<PackageReference Include="Fusonic.Extensions.AspNetCore" />
paket add Fusonic.Extensions.AspNetCore --version 9.5.4
#r "nuget: Fusonic.Extensions.AspNetCore, 9.5.4"
#:package Fusonic.Extensions.AspNetCore@9.5.4
#addin nuget:?package=Fusonic.Extensions.AspNetCore&version=9.5.4
#tool nuget:?package=Fusonic.Extensions.AspNetCore&version=9.5.4
ASP .Net Core Extensions
ServiceCollection extensions
services.AddAll<T>(IEnumerable<Assembly>)
registers all implementing classes of T in the given assemblies.
CultureUtil
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.
Examples:
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: de-AT (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)
CultureUtil.FromAcceptLanguageHeader(HttpContext, appSettings.SupportedCultures, appSettings.DefaultCulture)
Ignore paths Middleware
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");
Validation of Mediator requests
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.
To enable Mediator request validation, simply add the decorator RequestValidationDecorator
to IRequestHandler
:
// SimpleInjector
container.RegisterDecorator(typeof(IRequestHandler<,>), typeof(RequestValidationDecorator<,>));
// Scrutor
services.Decorate(typeof(IRequestHandler<,>), typeof(RequestValidationDecorator<,>));
You can then use the System.ComponentModel
-attributes and the IValidatableObject
-interface for validating your models. When model validation fails, a RequestValidationException
gets thrown containing all the model validation errors. You might want to handle that one in your Exception filter, if you have one.
Example:
public class GetSomething : IValidatableObject
{
[Required]
public string Search { get; set; }
[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.", new[] { nameof(From), nameof(To) });
}
}
This also works with records.
OpenTelemetry
Mediator tracing
To easily trace every request and notification sent by our Mediator-package, simply register the tracing decorators:
container.RegisterMediatorTracingDecorators();
container.RegisterMediator( /* Mediator configuration */ );
Also, when configuring the OpenTelemetry-Tracer, you need to enable the instrumentation:
services.AddOpenTelemetry()
.WithTracing(tracer => tracer.AddMediatorInstrumentation());
Note that the order matters. You must register the tracing decorators before mediator.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Fusonic.Extensions.Common (>= 9.5.4)
- Fusonic.Extensions.Mediator (>= 9.5.4)
- OpenTelemetry.Api (>= 1.9.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 |
---|---|---|
9.5.4 | 143 | 8/20/2025 |
9.5.3 | 371 | 3/28/2025 |
9.5.2 | 414 | 1/16/2025 |
9.5.0 | 277 | 10/4/2024 |
9.4.0 | 349 | 9/23/2024 |
9.3.1 | 263 | 9/11/2024 |
9.3.0 | 174 | 9/11/2024 |
9.2.0 | 191 | 8/8/2024 |
9.2.0-rc.3 | 82 | 8/7/2024 |
9.2.0-rc.2 | 65 | 8/5/2024 |
9.2.0-rc.1 | 70 | 8/1/2024 |
9.1.0 | 136 | 7/29/2024 |
9.0.0 | 733 | 7/17/2024 |
9.0.0-preview.2 | 87 | 6/13/2024 |
9.0.0-preview.1 | 133 | 4/5/2024 |
8.1.3 | 293 | 3/27/2024 |
8.1.2 | 178 | 3/27/2024 |
8.1.1 | 226 | 3/1/2024 |
8.1.0 | 1,265 | 1/26/2024 |
8.0.1 | 874 | 12/18/2023 |
8.0.1-rc.2 | 109 | 12/7/2023 |
8.0.1-rc.1 | 99 | 12/6/2023 |
8.0.0 | 358 | 11/21/2023 |
8.0.0-preview1 | 181 | 10/4/2023 |
7.4.0 | 168 | 1/25/2024 |
7.3.0 | 240 | 10/11/2023 |
7.2.1-rc.1 | 134 | 8/28/2023 |
7.2.0 | 609 | 6/28/2023 |
7.2.0-alpha.1 | 133 | 6/27/2023 |
7.1.2 | 481 | 5/25/2023 |
7.1.1 | 957 | 4/3/2023 |
7.1.1-rc.2 | 140 | 3/30/2023 |
7.1.1-rc.1 | 138 | 3/30/2023 |
7.1.0 | 863 | 2/28/2023 |
7.1.0-rc.1 | 155 | 2/20/2023 |
7.0.4-rc.5 | 159 | 2/23/2023 |
7.0.4-rc.4 | 156 | 2/23/2023 |
7.0.4-rc.3 | 149 | 2/23/2023 |
7.0.4-rc.2 | 151 | 2/22/2023 |
7.0.4-rc.1 | 154 | 2/16/2023 |
7.0.3 | 467 | 2/16/2023 |
7.0.2 | 350 | 2/9/2023 |
7.0.2-rc.1 | 170 | 2/2/2023 |
7.0.1 | 789 | 1/26/2023 |
7.0.0 | 404 | 1/24/2023 |
7.0.0-preview1 | 217 | 7/18/2022 |
7.0.0-beta.9 | 167 | 1/24/2023 |
7.0.0-beta.8 | 160 | 1/23/2023 |
7.0.0-beta.7 | 159 | 1/23/2023 |
7.0.0-beta.6 | 157 | 1/23/2023 |
7.0.0-beta.5 | 168 | 1/23/2023 |
7.0.0-beta.4 | 161 | 1/19/2023 |
7.0.0-beta.3 | 155 | 1/17/2023 |
7.0.0-beta.2 | 161 | 1/11/2023 |
7.0.0-beta.1 | 146 | 11/24/2022 |
6.2.2 | 15,725 | 9/20/2022 |
6.2.2-rc.1 | 174 | 9/19/2022 |
6.2.1 | 3,231 | 5/4/2022 |
6.2.0 | 612 | 4/21/2022 |
6.2.0-rc.2 | 204 | 4/21/2022 |
6.2.0-rc.1 | 198 | 4/20/2022 |
6.1.1 | 1,035 | 3/1/2022 |
6.1.0 | 700 | 2/10/2022 |
6.1.0-rc.3 | 197 | 2/10/2022 |
6.1.0-rc.2 | 189 | 2/10/2022 |
6.1.0-rc.1 | 204 | 2/9/2022 |
6.0.3 | 1,568 | 1/18/2022 |
6.0.2 | 3,505 | 1/10/2022 |
6.0.1 | 375 | 12/16/2021 |
6.0.0 | 879 | 12/13/2021 |
6.0.0-rc.6 | 243 | 12/6/2021 |
6.0.0-rc.5 | 412 | 12/6/2021 |
6.0.0-rc.4 | 587 | 12/6/2021 |
6.0.0-rc.3 | 455 | 12/6/2021 |
6.0.0-rc.2 | 427 | 12/6/2021 |
6.0.0-rc.1 | 730 | 11/15/2021 |
5.4.0 | 1,087 | 10/13/2021 |
5.3.0 | 594 | 9/23/2021 |
5.3.0-rc.1 | 417 | 9/17/2021 |
5.2.0 | 3,315 | 5/20/2021 |
5.2.0-rcjh.6 | 268 | 5/19/2021 |
5.2.0-rcjh.5 | 230 | 5/19/2021 |
5.2.0-rcjh.4 | 249 | 5/19/2021 |
5.2.0-rcjh.3 | 227 | 5/19/2021 |
5.2.0-rcjh.2 | 226 | 4/12/2021 |
5.2.0-rcjh.1 | 226 | 4/12/2021 |
5.1.3 | 431 | 5/19/2021 |
5.1.2 | 14,980 | 3/26/2021 |
5.1.1 | 1,107 | 1/13/2021 |
5.1.0 | 2,135 | 12/16/2020 |
5.0.0 | 2,582 | 11/17/2020 |
5.0.0-rc.1 | 360 | 10/15/2020 |
1.1.0 | 26,418 | 8/25/2020 |
1.0.2 | 744 | 8/19/2020 |
1.0.1 | 2,871 | 7/3/2020 |
1.0.0 | 599 | 6/15/2020 |