TiqriGlobalShop.Common.AspNetCore
1.1.0
dotnet add package TiqriGlobalShop.Common.AspNetCore --version 1.1.0
NuGet\Install-Package TiqriGlobalShop.Common.AspNetCore -Version 1.1.0
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="TiqriGlobalShop.Common.AspNetCore" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TiqriGlobalShop.Common.AspNetCore" Version="1.1.0" />
<PackageReference Include="TiqriGlobalShop.Common.AspNetCore" />
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 TiqriGlobalShop.Common.AspNetCore --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TiqriGlobalShop.Common.AspNetCore, 1.1.0"
#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 TiqriGlobalShop.Common.AspNetCore@1.1.0
#: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=TiqriGlobalShop.Common.AspNetCore&version=1.1.0
#tool nuget:?package=TiqriGlobalShop.Common.AspNetCore&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GlobalShop.Common.AspNetCore
Shared ASP.NET Core infrastructure for GlobalShop web APIs.
Features
Exception Handlers — Production-ready
IExceptionHandlerimplementations:CancellationExceptionHandler— Handles client-cancelled requests (HTTP 499)ConcurrencyExceptionHandler— Handles EF Core optimistic concurrency conflicts (HTTP 409)PostgresExceptionHandler— Maps PostgreSQL error codes to appropriate HTTP responsesDatabaseExceptionHandler— Handles general database connectivity errors (HTTP 503)GlobalExceptionHandler— Catch-all for unhandled exceptions (HTTP 500), with dev-mode details
Middleware
RequestContextLoggingMiddleware— Extracts/generatesX-Correlation-Idand pushes it into the SerilogLogContext
Minimal API Endpoints
IEndpoint— Interface for discoverable minimal API endpointsEndpointExtensions— Auto-discovers and mapsIEndpointimplementations from an assembly
Problem Details
AddCommonProblemDetails()— Configures RFC 9457 Problem Details withtraceId,timestamp, andinstance
API Versioning
AddCommonApiVersioning()— Header-based API versioning with sensible defaultsConfigureSwaggerVersioningOptions— Auto-generates versioned Swagger documents
Swagger / OpenAPI
SwaggerDefaultValues— Populates default API version parameters, deprecation markers, and response content typesApiVersionHeaderOperationFilter— Addsx-api-versionheader parameter to all Swagger operationsServiceCollectionExtensions.AddSwaggerGenWithJwtAuth()— Configures Swagger with JWT Bearer authenticationApplicationBuilderExtensions.UseSwaggerWithUi()— Enables Swagger + Swagger UI middlewareApplicationBuilderExtensions.UseSwaggerWithVersionedUi()— Enables Swagger UI with per-version endpoints
Database Migrations
ApplyMigrations<TDbContext>()— Resilient EF Core migration runner with Polly retry (exponential backoff + jitter)
Health Checks
MapCommonHealthChecks()— Maps a health check endpoint with detailed JSON response
Result Pattern Helpers
ResultExtensions.Match()— Pattern-match onResult/Result<T>for railway-oriented endpoint handlersCustomResults.Problem()— ConvertsResultfailures to RFC 9457 Problem Details responses
JSON Patch
JsonPatchBinder<TModel>— Base class for model-bindingJsonPatchDocument<T>
Installation
dotnet add package GlobalShop.Common.AspNetCore
Quick Start
Register Exception Handlers
// In Program.cs or ConfigureServices
builder.Services.AddCommonProblemDetails(); // RFC 9457 with traceId, timestamp, instance
builder.Services.AddCommonExceptionHandlers(); // registers all 5 handlers
// ...
app.UseExceptionHandler();
API Versioning
// Header-based versioning with x-api-version header
builder.Services.AddCommonApiVersioning();
// Versioned Swagger docs
builder.Services.AddTransient<IConfigureOptions<SwaggerGenOptions>>(sp =>
new ConfigureSwaggerVersioningOptions(
sp.GetRequiredService<IApiVersionDescriptionProvider>(),
apiTitle: "My API",
apiDescription: "My API description"
));
builder.Services.AddSwaggerGenWithJwtAuth();
// In dev mode
app.UseSwaggerWithVersionedUi();
Resilient Database Migrations
if (app.Environment.IsDevelopment())
{
app.ApplyMigrations<MyDbContext>(); // Polly retry for NpgsqlException
}
Health Checks
app.MapCommonHealthChecks(); // maps /health endpoint
Use Correlation ID Middleware
app.UseRequestContextLogging(); // adds X-Correlation-Id to Serilog LogContext
app.UseSerilogRequestLogging();
Discover Minimal API Endpoints
// Register
builder.Services.AddEndpoints(Assembly.GetExecutingAssembly());
// Map
app.MapEndpoints();
Result Pattern Helpers
using GlobalShop.Common.AspNetCore.Extensions;
using GlobalShop.Common.AspNetCore.Results;
// In a minimal API endpoint handler
return result.Match(Results.Ok, CustomResults.Problem);
Dependencies
| Package | Purpose |
|---|---|
GlobalShop.Common.SharedKernel |
Result/Error types for CustomResults and ResultExtensions |
Microsoft.AspNetCore.App (framework) |
Core ASP.NET types |
Microsoft.AspNetCore.Authentication.JwtBearer |
JWT Bearer auth for Swagger |
Microsoft.EntityFrameworkCore |
Concurrency/database exception handling, migrations |
Npgsql.EntityFrameworkCore.PostgreSQL |
PostgreSQL exception handling |
Serilog |
Log context for correlation IDs |
Swashbuckle.AspNetCore |
Swagger operation filters |
Asp.Versioning.Http |
Header-based API version reader |
Asp.Versioning.Mvc.ApiExplorer |
API versioning support |
Microsoft.AspNetCore.JsonPatch |
JSON Patch model binding |
Microsoft.Extensions.Resilience |
Polly resilience for migrations |
Microsoft.Extensions.Diagnostics.HealthChecks |
Health check abstractions |
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Asp.Versioning.Http (>= 8.1.1)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.1)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.2)
- Microsoft.AspNetCore.JsonPatch (>= 10.0.2)
- Microsoft.EntityFrameworkCore (>= 10.0.1)
- Microsoft.Extensions.Resilience (>= 10.0.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.0)
- Serilog (>= 4.3.0)
- Swashbuckle.AspNetCore (>= 10.1.1)
- TiqriGlobalShop.Common.SharedKernel (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.