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" />
                    
Directory.Packages.props
<PackageReference Include="TiqriGlobalShop.Common.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 TiqriGlobalShop.Common.AspNetCore --version 1.1.0
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=TiqriGlobalShop.Common.AspNetCore&version=1.1.0
                    
Install as a Cake Tool

GlobalShop.Common.AspNetCore

Shared ASP.NET Core infrastructure for GlobalShop web APIs.

Features

  • Exception Handlers — Production-ready IExceptionHandler implementations:

    • CancellationExceptionHandler — Handles client-cancelled requests (HTTP 499)
    • ConcurrencyExceptionHandler — Handles EF Core optimistic concurrency conflicts (HTTP 409)
    • PostgresExceptionHandler — Maps PostgreSQL error codes to appropriate HTTP responses
    • DatabaseExceptionHandler — Handles general database connectivity errors (HTTP 503)
    • GlobalExceptionHandler — Catch-all for unhandled exceptions (HTTP 500), with dev-mode details
  • Middleware

    • RequestContextLoggingMiddleware — Extracts/generates X-Correlation-Id and pushes it into the Serilog LogContext
  • Minimal API Endpoints

    • IEndpoint — Interface for discoverable minimal API endpoints
    • EndpointExtensions — Auto-discovers and maps IEndpoint implementations from an assembly
  • Problem Details

    • AddCommonProblemDetails() — Configures RFC 9457 Problem Details with traceId, timestamp, and instance
  • API Versioning

    • AddCommonApiVersioning() — Header-based API versioning with sensible defaults
    • ConfigureSwaggerVersioningOptions — Auto-generates versioned Swagger documents
  • Swagger / OpenAPI

    • SwaggerDefaultValues — Populates default API version parameters, deprecation markers, and response content types
    • ApiVersionHeaderOperationFilter — Adds x-api-version header parameter to all Swagger operations
    • ServiceCollectionExtensions.AddSwaggerGenWithJwtAuth() — Configures Swagger with JWT Bearer authentication
    • ApplicationBuilderExtensions.UseSwaggerWithUi() — Enables Swagger + Swagger UI middleware
    • ApplicationBuilderExtensions.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 on Result / Result<T> for railway-oriented endpoint handlers
    • CustomResults.Problem() — Converts Result failures to RFC 9457 Problem Details responses
  • JSON Patch

    • JsonPatchBinder<TModel> — Base class for model-binding JsonPatchDocument<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 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.

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
1.1.0 179 2/10/2026
1.0.0 140 2/10/2026