CSharpEssentials.AspNetCore
3.0.2
See the version list below for details.
dotnet add package CSharpEssentials.AspNetCore --version 3.0.2
NuGet\Install-Package CSharpEssentials.AspNetCore -Version 3.0.2
<PackageReference Include="CSharpEssentials.AspNetCore" Version="3.0.2" />
<PackageVersion Include="CSharpEssentials.AspNetCore" Version="3.0.2" />
<PackageReference Include="CSharpEssentials.AspNetCore" />
paket add CSharpEssentials.AspNetCore --version 3.0.2
#r "nuget: CSharpEssentials.AspNetCore, 3.0.2"
#:package CSharpEssentials.AspNetCore@3.0.2
#addin nuget:?package=CSharpEssentials.AspNetCore&version=3.0.2
#tool nuget:?package=CSharpEssentials.AspNetCore&version=3.0.2
CSharpEssentials.AspNetCore
CSharpEssentials.AspNetCore provides essential utilities and middleware for building production-ready ASP.NET Core Web APIs. It integrates seamlessly with the CSharpEssentials.Errors ecosystem to provide structured error responses and simplifies common configurations like Swagger and API Versioning.
🚀 Features
- Global Exception Handler: Middleware (
IExceptionHandler) that catches exceptions and converts them into standard RFC 7807ProblemDetailsresponses. - Enhanced Problem Details: Extends
ProblemDetailsto include structured error codes and messages fromCSharpEssentials.Errors. - Swagger Configuration: Easy setup for Swagger with support for API Versioning and custom schema filters.
- API Versioning: Pre-configured extensions for setting up API versioning (URL segment + Header).
📦 Installation
dotnet add package CSharpEssentials.AspNetCore
🛠 Usage
1. Global Exception Handling
Register the global exception handler to automatically convert DomainException, ValidationException, and others into structured JSON error responses.
using CSharpEssentials.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
// Add problem details support
builder.Services.AddProblemDetails();
// Register the handler
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
Then, in your middleware pipeline:
var app = builder.Build();
app.UseExceptionHandler(); // Uses the registered GlobalExceptionHandler
2. API Versioning
Enable standard API versioning (URL Segment + Header support) with a single line.
using CSharpEssentials.AspNetCore;
builder.Services.AddAndConfigureApiVersioning();
3. Swagger with Versioning
Simplify Swagger configuration, especially when using API versioning.
using CSharpEssentials.AspNetCore;
// Add Swagger services
builder.Services.AddSwagger<ConfigureSwaggerOptions>(
securityScheme: SecuritySchemes.Bearer // Or your custom scheme
);
// Use Swagger Middleware
app.UseVersionableSwagger();
4. Structured Error Responses
When an exception occurs (e.g., DomainException from CSharpEssentials.Errors), the response will look like this:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "Bad Request",
"status": 400,
"errors": [
{
"code": "User.InvalidEmail",
"description": "The email format is incorrect.",
"type": "Validation"
}
],
"errorCodes": [ "User.InvalidEmail" ]
}
| 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 is compatible. 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 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. net11.0 is compatible. |
-
net10.0
- Asp.Versioning.Abstractions (>= 10.0.0)
- Asp.Versioning.Http (>= 8.1.0)
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- CSharpEssentials.Errors (>= 3.0.2)
- CSharpEssentials.Json (>= 3.0.2)
- CSharpEssentials.Results (>= 3.0.2)
- Swashbuckle.AspNetCore (>= 8.1.0)
-
net11.0
- Asp.Versioning.Abstractions (>= 10.0.0)
- Asp.Versioning.Http (>= 8.1.0)
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- CSharpEssentials.Errors (>= 3.0.2)
- CSharpEssentials.Json (>= 3.0.2)
- CSharpEssentials.Results (>= 3.0.2)
- Swashbuckle.AspNetCore (>= 8.1.0)
-
net8.0
- Asp.Versioning.Abstractions (>= 10.0.0)
- Asp.Versioning.Http (>= 8.1.0)
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- CSharpEssentials.Errors (>= 3.0.2)
- CSharpEssentials.Json (>= 3.0.2)
- CSharpEssentials.Results (>= 3.0.2)
- Swashbuckle.AspNetCore (>= 8.1.0)
- System.Text.Json (>= 9.0.0)
-
net9.0
- Asp.Versioning.Abstractions (>= 10.0.0)
- Asp.Versioning.Http (>= 8.1.0)
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- CSharpEssentials.Errors (>= 3.0.2)
- CSharpEssentials.Json (>= 3.0.2)
- CSharpEssentials.Results (>= 3.0.2)
- Swashbuckle.AspNetCore (>= 8.1.0)
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 |
|---|---|---|
| 3.0.3 | 0 | 5/5/2026 |
| 3.0.2 | 13 | 5/5/2026 |
| 3.0.1 | 57 | 5/3/2026 |
| 3.0.0 | 58 | 5/3/2026 |
| 2.1.0 | 222 | 11/26/2025 |
| 2.0.9 | 228 | 9/30/2025 |
| 2.0.8 | 214 | 9/29/2025 |
| 2.0.7 | 198 | 9/29/2025 |
| 2.0.6 | 207 | 9/29/2025 |
| 2.0.5 | 209 | 9/29/2025 |
| 2.0.4 | 219 | 9/28/2025 |
| 2.0.3 | 209 | 9/28/2025 |
| 2.0.2 | 204 | 9/28/2025 |
| 2.0.1 | 203 | 9/28/2025 |
| 2.0.0 | 209 | 9/28/2025 |
| 1.0.15 | 492 | 2/4/2025 |
| 1.0.14 | 386 | 1/29/2025 |
| 1.0.13 | 201 | 12/27/2024 |
| 1.0.12 | 184 | 12/18/2024 |
| 1.0.11 | 170 | 12/18/2024 |