TinyHelpers.AspNetCore
3.1.17
See the version list below for details.
dotnet add package TinyHelpers.AspNetCore --version 3.1.17
NuGet\Install-Package TinyHelpers.AspNetCore -Version 3.1.17
<PackageReference Include="TinyHelpers.AspNetCore" Version="3.1.17" />
paket add TinyHelpers.AspNetCore --version 3.1.17
#r "nuget: TinyHelpers.AspNetCore, 3.1.17"
// Install TinyHelpers.AspNetCore as a Cake Addin #addin nuget:?package=TinyHelpers.AspNetCore&version=3.1.17 // Install TinyHelpers.AspNetCore as a Cake Tool #tool nuget:?package=TinyHelpers.AspNetCore&version=3.1.17
Tiny Helpers for ASP.NET Core
A collection of helper methods and classes for ASP.NET Core that I use every day. I have packed them in a single library to avoid code duplication.
Installation
The library is available on NuGet. Just search for TinyHelpers.AspNetCore in the Package Manager GUI or run the following command in the .NET CLI:
dotnet add package TinyHelpers.AspNetCore
Usage
The library provides some useful extension methods for ASP.NET Core applications.
AddDefaultProblemDetails()
: available in .NET 7.0 and greater, it calls the default ProblemDetails extension method defining the CustomizeProblemDetails property to ensure that all the typical properties (Type, Title, Instance, TraceId) are correctly set.AddDefaultExceptionHandler()
: available in .NET 8.0 and greater, it adds a default implementation for the IExceptionHandler interface that returns the following response on exceptions:
app.MapPost("/api/exception", () =>
{
throw new Exception("This is an exception", innerException: new HttpRequestException("This is an inner exception"));
})
.WithOpenApi();
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.6.1",
"title": "System.Exception",
"status": 500,
"detail": "This is an exception",
"instance": "/api/exception",
"traceId": "00-1bffa22c7288e5784bf763d5fd05bc87-87da01a1b76d1692-00",
"innerException": "System.Net.Http.HttpRequestException",
"innerExceptionMessage": "This is an inner exception",
"stackTrace": "..."
}
Note The StackTrace property is included in the response only if the application is running in the Development environment.
AddRequestLocalization(cultures)
: an overload of the standard AddRequestLocalization extension method that just requires the list of supported cultures and automatically registers the corresponding RequestLocalizationOptions (Note: The first culture in the list is used as the default culture).AddAcceptLanguageHeader
: an extension method for Swagger. It adds the Accept-Language header to swagger.json definition.
builder.Services.AddSwaggerGen(options =>
{
options.AddAcceptLanguageHeader();
});
ConfigureAndGet<TOptions>( )
: it allows to register a configuration instance on type TOptions and returns the instance itself. It is useful when you need to configure the options and gets the reference to that instance in the same method, typically at application startup.
Contribute
The project is constantly evolving. Contributions are welcome. Feel free to file issues and pull requests on the repo and we'll address them as we can.
Warning Remember to work on the develop branch, don't use the master branch directly. Create Pull Requests targeting develop.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.8.1)
-
net7.0
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.8.1)
-
net8.0
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.8.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on TinyHelpers.AspNetCore:
Repository | Stars |
---|---|
marcominerva/ChatGptNet
A ChatGPT integration library for .NET, supporting both OpenAI and Azure OpenAI Service
|
|
marcominerva/MinimalHelpers
A collection of helpers libraries for Minimal API projects.
|
Version | Downloads | Last updated |
---|---|---|
4.0.6 | 163 | 12/11/2024 |
4.0.5 | 135 | 12/4/2024 |
3.2.3 | 92 | 12/2/2024 |
3.2.2 | 111 | 11/22/2024 |
3.1.19 | 526 | 10/15/2024 |
3.1.17 | 261 | 9/30/2024 |
3.1.16 | 135 | 9/26/2024 |
3.1.15 | 108 | 9/24/2024 |
3.1.9 | 290 | 9/2/2024 |
3.1.8 | 160 | 8/1/2024 |
3.1.6 | 592 | 6/19/2024 |
3.1.4 | 621 | 5/14/2024 |
3.0.6 | 906 | 2/15/2024 |
3.0.5 | 199 | 1/31/2024 |
3.0.4 | 291 | 1/8/2024 |
3.0.2 | 700 | 11/15/2023 |
2.0.24 | 785 | 9/4/2023 |
2.0.23 | 666 | 7/11/2023 |
2.0.22 | 229 | 6/20/2023 |
2.0.20 | 379 | 4/13/2023 |
2.0.19 | 237 | 4/10/2023 |
2.0.17 | 242 | 3/27/2023 |
2.0.12 | 345 | 3/1/2023 |
2.0.10 | 425 | 1/11/2023 |
2.0.9 | 298 | 1/9/2023 |
2.0.3 | 550 | 11/30/2022 |
1.0.32 | 440 | 10/31/2022 |
1.0.26 | 545 | 9/21/2022 |
1.0.7 | 428 | 7/25/2022 |
1.0.6 | 437 | 7/6/2022 |
1.0.5 | 414 | 6/30/2022 |
1.0.4 | 425 | 6/21/2022 |