Fusonic.Extensions.AspNetCore
8.0.0-preview1
Prefix Reserved
See the version list below for details.
dotnet add package Fusonic.Extensions.AspNetCore --version 8.0.0-preview1
NuGet\Install-Package Fusonic.Extensions.AspNetCore -Version 8.0.0-preview1
<PackageReference Include="Fusonic.Extensions.AspNetCore" Version="8.0.0-preview1" />
paket add Fusonic.Extensions.AspNetCore --version 8.0.0-preview1
#r "nuget: Fusonic.Extensions.AspNetCore, 8.0.0-preview1"
// Install Fusonic.Extensions.AspNetCore as a Cake Addin #addin nuget:?package=Fusonic.Extensions.AspNetCore&version=8.0.0-preview1&prerelease // Install Fusonic.Extensions.AspNetCore as a Cake Tool #tool nuget:?package=Fusonic.Extensions.AspNetCore&version=8.0.0-preview1&prerelease
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 MediatR requests
MediatR 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 MediatR 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.
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. |
-
net8.0
- Fusonic.Extensions.Common (>= 8.0.0-preview1)
- MediatR (>= 11.1.0 && < 12.0.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.2 | 39 | 1/16/2025 |
9.5.0 | 201 | 10/4/2024 |
9.4.0 | 264 | 9/23/2024 |
9.3.1 | 212 | 9/11/2024 |
9.3.0 | 134 | 9/11/2024 |
9.2.0 | 151 | 8/8/2024 |
9.2.0-rc.3 | 63 | 8/7/2024 |
9.2.0-rc.2 | 41 | 8/5/2024 |
9.2.0-rc.1 | 55 | 8/1/2024 |
9.1.0 | 97 | 7/29/2024 |
9.0.0 | 522 | 7/17/2024 |
9.0.0-preview.2 | 74 | 6/13/2024 |
9.0.0-preview.1 | 117 | 4/5/2024 |
8.1.3 | 255 | 3/27/2024 |
8.1.2 | 135 | 3/27/2024 |
8.1.1 | 186 | 3/1/2024 |
8.1.0 | 1,233 | 1/26/2024 |
8.0.1 | 700 | 12/18/2023 |
8.0.1-rc.2 | 94 | 12/7/2023 |
8.0.1-rc.1 | 84 | 12/6/2023 |
8.0.0 | 342 | 11/21/2023 |
8.0.0-preview1 | 162 | 10/4/2023 |
7.4.0 | 132 | 1/25/2024 |
7.3.0 | 220 | 10/11/2023 |
7.2.1-rc.1 | 102 | 8/28/2023 |
7.2.0 | 570 | 6/28/2023 |
7.2.0-alpha.1 | 97 | 6/27/2023 |
7.1.2 | 437 | 5/25/2023 |
7.1.1 | 911 | 4/3/2023 |
7.1.1-rc.2 | 98 | 3/30/2023 |
7.1.1-rc.1 | 94 | 3/30/2023 |
7.1.0 | 813 | 2/28/2023 |
7.1.0-rc.1 | 110 | 2/20/2023 |
7.0.4-rc.5 | 109 | 2/23/2023 |
7.0.4-rc.4 | 104 | 2/23/2023 |
7.0.4-rc.3 | 100 | 2/23/2023 |
7.0.4-rc.2 | 107 | 2/22/2023 |
7.0.4-rc.1 | 109 | 2/16/2023 |
7.0.3 | 420 | 2/16/2023 |
7.0.2 | 303 | 2/9/2023 |
7.0.2-rc.1 | 122 | 2/2/2023 |
7.0.1 | 742 | 1/26/2023 |
7.0.0 | 354 | 1/24/2023 |
7.0.0-preview1 | 155 | 7/18/2022 |
7.0.0-beta.9 | 119 | 1/24/2023 |
7.0.0-beta.8 | 110 | 1/23/2023 |
7.0.0-beta.7 | 112 | 1/23/2023 |
7.0.0-beta.6 | 109 | 1/23/2023 |
7.0.0-beta.5 | 120 | 1/23/2023 |
7.0.0-beta.4 | 115 | 1/19/2023 |
7.0.0-beta.3 | 109 | 1/17/2023 |
7.0.0-beta.2 | 112 | 1/11/2023 |
7.0.0-beta.1 | 96 | 11/24/2022 |
6.2.2 | 15,060 | 9/20/2022 |
6.2.2-rc.1 | 127 | 9/19/2022 |
6.2.1 | 3,167 | 5/4/2022 |
6.2.0 | 549 | 4/21/2022 |
6.2.0-rc.2 | 144 | 4/21/2022 |
6.2.0-rc.1 | 135 | 4/20/2022 |
6.1.1 | 970 | 3/1/2022 |
6.1.0 | 635 | 2/10/2022 |
6.1.0-rc.3 | 132 | 2/10/2022 |
6.1.0-rc.2 | 124 | 2/10/2022 |
6.1.0-rc.1 | 136 | 2/9/2022 |
6.0.3 | 1,503 | 1/18/2022 |
6.0.2 | 3,437 | 1/10/2022 |
6.0.1 | 306 | 12/16/2021 |
6.0.0 | 812 | 12/13/2021 |
6.0.0-rc.6 | 171 | 12/6/2021 |
6.0.0-rc.5 | 347 | 12/6/2021 |
6.0.0-rc.4 | 521 | 12/6/2021 |
6.0.0-rc.3 | 391 | 12/6/2021 |
6.0.0-rc.2 | 364 | 12/6/2021 |
6.0.0-rc.1 | 666 | 11/15/2021 |
5.4.0 | 1,018 | 10/13/2021 |
5.3.0 | 527 | 9/23/2021 |
5.3.0-rc.1 | 349 | 9/17/2021 |
5.2.0 | 3,249 | 5/20/2021 |
5.2.0-rcjh.6 | 202 | 5/19/2021 |
5.2.0-rcjh.5 | 161 | 5/19/2021 |
5.2.0-rcjh.4 | 184 | 5/19/2021 |
5.2.0-rcjh.3 | 159 | 5/19/2021 |
5.2.0-rcjh.2 | 153 | 4/12/2021 |
5.2.0-rcjh.1 | 155 | 4/12/2021 |
5.1.3 | 362 | 5/19/2021 |
5.1.2 | 14,396 | 3/26/2021 |
5.1.1 | 1,025 | 1/13/2021 |
5.1.0 | 2,051 | 12/16/2020 |
5.0.0 | 2,499 | 11/17/2020 |
5.0.0-rc.1 | 282 | 10/15/2020 |
1.1.0 | 26,324 | 8/25/2020 |
1.0.2 | 661 | 8/19/2020 |
1.0.1 | 2,791 | 7/3/2020 |
1.0.0 | 516 | 6/15/2020 |