Alvecta.Foundation.Presentation.WebApi.AspNetCore 7.0.73

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

Alvecta.Foundation.Presentation.WebApi.AspNetCore

Maps Alvecta use cases (Alvecta.Foundation.Application.Contracts) as ASP.NET Core minimal-API endpoints, one line per use case, and adds a /version endpoint. Formerly Alvecta.Foundation.Api.AspNetCore.

It belongs to the Presentation layer: an inbound (driving) adapter that calls use-case interfaces and never sees their implementations. Dependencies: the Microsoft.AspNetCore.App shared framework, Alvecta.Utils, Alvecta.Utils.UserExceptions and Alvecta.Foundation.Application.Contracts.

What it contains

Extension methods on IEndpointRouteBuilder:

Method Use case Endpoint
MapUseCase<TUseCase>() IUseCase POST, no body, no result
MapUseCase<TUseCase, TRequest>() IUseCase<TRequest> POST, JSON body, no result
MapUseCase<TUseCase, TRequest, TResponse>() IUseCase<TRequest, TResponse> POST, JSON body, JSON result
MapUseCaseWithoutRequest<TUseCase, TResponse>() IUseCaseWithoutRequest<TResponse> POST, no body, JSON result
MapVersionEndpoint() — GET /version, anonymous, the entry assembly's informational version as text
  • Routes come from the interface name. The leading I and the trailing UseCase are removed: IGetOrderUseCase maps to GetOrder, relative to the route group. TUseCase must be an interface named that way, otherwise mapping throws at startup.
  • Every use case is a POST. The use case is resolved from DI per request.
  • Requests are validated first. When a request implements IValidatable (Alvecta.Utils.Validation), its Validate() runs before the use case, and any errors are thrown as a UserException.
  • Each method returns the RouteHandlerBuilder, so authorization, filters and metadata chain on as usual.

Usage

dotnet add package Alvecta.Foundation.Presentation.WebApi.AspNetCore
using Alvecta.Foundation.Application.Contracts.Database;
using Alvecta.Foundation.Presentation.WebApi.AspNetCore;

var app = builder.Build();

app.MapVersionEndpoint();

var orders = app.MapGroup("/api/orders").RequireAuthorization();
orders.MapUseCase<IGetOrderUseCase, IGetOrderUseCase.Request, IGetOrderUseCase.Response>(); // POST /api/orders/GetOrder
orders.MapUseCase<ICancelOrderUseCase, ICancelOrderUseCase.Request>();                      // POST /api/orders/CancelOrder

var database = app.MapGroup("/api/database").RequireAuthorization("ApiKeyPolicy");
database.MapUseCase<IMigrateDatabaseUseCase>();                                            // POST /api/database/MigrateDatabase

app.Run();

Turning a UserException into an HTTP response is up to the host, for example with the UserExceptionHandlingMiddleware from Alvecta.Utils.AspNetCore.

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
7.0.73 0 10/23/2026
7.0.72 0 10/23/2026
7.0.71 0 10/23/2026
7.0.70 37 10/22/2026
7.0.69 48 10/21/2026
7.0.68 41 10/21/2026
7.0.67 51 10/20/2026
7.0.66 62 10/19/2026
7.0.65 76 10/19/2026
6.3.64 82 10/19/2026
6.3.63 77 10/19/2026
6.2.62 88 10/14/2026
6.1.61 93 10/9/2026
6.1.60 85 10/7/2026
6.1.59 95 10/6/2026
6.1.58 92 10/5/2026
6.0.57 98 10/2/2026
6.0.56 101 10/1/2026
6.0.55 90 10/1/2026
5.0.54 103 9/30/2026
Loading failed