CSharpEssentials.AspNetCore 3.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package CSharpEssentials.AspNetCore --version 3.0.1
                    
NuGet\Install-Package CSharpEssentials.AspNetCore -Version 3.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpEssentials.AspNetCore" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpEssentials.AspNetCore" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CSharpEssentials.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharpEssentials.AspNetCore --version 3.0.1
                    
#r "nuget: CSharpEssentials.AspNetCore, 3.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharpEssentials.AspNetCore@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharpEssentials.AspNetCore&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CSharpEssentials.AspNetCore&version=3.0.1
                    
Install as a Cake Tool

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 7807 ProblemDetails responses.
  • Enhanced Problem Details: Extends ProblemDetails to include structured error codes and messages from CSharpEssentials.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 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed