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
<PackageReference Include="Netrilo.Infrastructure.Common.Web" Version="1.0.4" />
<PackageVersion Include="Netrilo.Infrastructure.Common.Web" Version="1.0.4" />
<PackageReference Include="Netrilo.Infrastructure.Common.Web" />
paket add Netrilo.Infrastructure.Common.Web --version 1.0.4
#r "nuget: Netrilo.Infrastructure.Common.Web, 1.0.4"
#:package Netrilo.Infrastructure.Common.Web@1.0.4
#addin nuget:?package=Netrilo.Infrastructure.Common.Web&version=1.0.4
#tool nuget:?package=Netrilo.Infrastructure.Common.Web&version=1.0.4
Netrilo.Infrastructure.Common.Web
Part of the Netrilo.Infrastructure SDK
📦 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 | Versions 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. |
-
net9.0
- Consul (>= 1.7.14.9)
- FluentValidation (>= 12.0.0)
- FluentValidation.AspNetCore (>= 11.3.1)
- MediatR (>= 13.0.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.23.0)
- Microsoft.AspNetCore.Hosting (>= 2.3.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 9.0.9)
- Microsoft.Extensions.Configuration (>= 9.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.9)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.9)
- Microsoft.Extensions.DependencyInjection (>= 9.0.9)
- Microsoft.Extensions.Hosting (>= 9.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.9)
- Netrilo.Infrastructure.Common.Abstractions (>= 1.0.4)
- Swashbuckle.AspNetCore (>= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.