Netrilo.Infrastructure.Common.Web 1.0.4

dotnet add package Netrilo.Infrastructure.Common.Web --version 1.0.4
                    
NuGet\Install-Package Netrilo.Infrastructure.Common.Web -Version 1.0.4
                    
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="Netrilo.Infrastructure.Common.Web" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Netrilo.Infrastructure.Common.Web" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Netrilo.Infrastructure.Common.Web" />
                    
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 Netrilo.Infrastructure.Common.Web --version 1.0.4
                    
#r "nuget: Netrilo.Infrastructure.Common.Web, 1.0.4"
                    
#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 Netrilo.Infrastructure.Common.Web@1.0.4
                    
#: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=Netrilo.Infrastructure.Common.Web&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Netrilo.Infrastructure.Common.Web&version=1.0.4
                    
Install as a Cake Tool

Netrilo.Infrastructure.Common.Web

Part of the Netrilo.Infrastructure SDK

📦 NuGet

NuGet

📖 Description

The Netrilo.Infrastructure.Common.Web package provides ready-to-use extensions for ASP.NET Core applications, bundling together common infrastructure concerns such as:

  • 🚀 Swagger/OpenAPI with configuration from appsettings.json
  • 🧩 FluentValidation auto-registration (by reflection of provided assemblies)
  • 🛡 Global exception handling via ExceptionFilter
  • 📡 Consul for service discovery and health checks
  • 📊 Application Insights integration
  • ❤️ Health checks and telemetry
  • MediatR validation pipeline (ValidationBehavior<,>)
  • 🔗 Automatic JSON enum serialization using StringEnumConverter

Installation

Add a project reference or NuGet package for Netrilo.Infrastructure.Common.Web.

dotnet add package Netrilo.Infrastructure.Common.Web

Service Registration

The entry point is the AddCommonWeb method:

builder.Services.AddCommonWeb(builder.Configuration, typeof(CreateUserValidator));

What it does:

  • Registers all validators in the provided assemblies (params Type[] validatorTypes)
  • Adds FluentValidation auto-validation and client-side adapters
  • Adds MVC with global ExceptionFilter
  • Configures Newtonsoft.Json enum serialization
  • Registers Swagger/OpenAPI
  • Registers health checks
  • Adds MediatR validation pipeline behavior
  • Adds Application Insights telemetry

Middleware Configuration

The unified entry point is UseCommonWeb:

app.UseCommonWeb(builder.Configuration, app.Lifetime);

What it does:

  • Configures Swagger UI and OpenAPI docs
  • Registers service with Consul and sets up deregistration on shutdown (IHostApplicationLifetime)
  • Future-proof: additional middlewares (CORS, Telemetry, etc.) can be chained here

Example Program.cs

using Netrilo.Infrastructure.Common.Web;

var builder = WebApplication.CreateBuilder(args);

// Register web infrastructure, validators, and common services
builder.Services.AddCommonWeb(builder.Configuration, typeof(CreateUserValidator));

var app = builder.Build();

// Configure request pipeline with Swagger + Consul + health checks
app.UseCommonWeb(builder.Configuration, app.Lifetime);

app.MapControllers();
app.Run();

Swagger Configuration (appsettings.json)

{
  "Swagger": {
    "Title": "My API",
    "Version": "v1",
    "Description": "API documentation powered by Swagger"
  },
  "Consul": {
    "ServiceId": "my-api-service",
    "ServiceName": "MyApi",
    "Host": "localhost",
    "Port": 5000,
    "ConsulAddress": "http://localhost:8500"
  },
  "ApplicationInsights": {
    "InstrumentationKey": "YOUR-KEY-HERE"
  }
}

Health Checks

Adding health checks by decorating your services via using AddCommonWeb function will be automatically exposed via the configured health endpoint.

✅ This makes your web project production-ready in just a few lines.

📄 License

MIT License

Product Compatible and additional computed target framework versions.
.NET 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
1.0.4 314 9/15/2025
1.0.3 271 9/15/2025
1.0.2 121 9/12/2025
1.0.1 126 9/12/2025