Despro.Framework.Presentation.Api 2.1.1

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

Despro.Framework.Presentation.Api

The controller-based presentation flavor of Despro Framework.

Despro.Framework.Presentation.Api specializes Despro.Framework.Presentation for controller-based Web APIs. It provides a base ApiController that turns domain OperationResult/OperationQueryResult values into the standardized ApiResult envelope, plus a route-prefix convention and Newtonsoft-based JSON configuration.

  • Package: Despro.Framework.Presentation.Api
  • Version: 2.0.8
  • Target framework: net10.0
  • Depends on: Despro.Framework.Presentation

Installation

dotnet add package Despro.Framework.Presentation.Api

Setup

using Despro.Framework.Presentation;
using Despro.Framework.Presentation.Api;

// shared presentation services (JWT, Swagger, CORS, Mapster, HSTS)
builder.Services.AddFrameworkPresentationWeb(builder.Configuration, "My Application", "DefaultCorsPolicy");
// controller-based services
builder.Services.AddFrameworkPresentationWebApi(RoutePrefix: "v{version:apiVersion}/[controller]");

var app = builder.Build();
app.UseFrameworkPresentationWeb(ShowSwaggerInProduction: false);
app.UseFrameworkPresentationWebApi(); // maps controllers
app.Run();

AddFrameworkPresentationWebApi configures controllers with a RoutePrefixConvention, Newtonsoft JSON (DefaultContractResolver, null naming policy) and converts invalid ModelState into a thrown exception (handled by the shared exception middleware). UseFrameworkPresentationWebApi calls MapControllers().


Key components

ApiController (ControllerTools)

An [ApiController] / [ApiVersion(1.0)] base ControllerBase with helpers that build an ApiResult, set the HTTP status code from the mapped AppStatusCode, and cover the command and query cases:

Method Input → Output
CommandResult(OperationResult) command with no payload
CommandResult<TData>(OperationResult<TData>) command with payload
QueryResult<TData>(TData) raw query result (always success)
QueryResult<TData>(OperationQueryResult<TData>) query with status

RoutePrefixConvention (Utilites)

An IApplicationModelConvention that applies the configured route prefix (e.g. v{version:apiVersion}/[controller]) to every [ApiController].


Usage

public class ProductsController(ISender sender) : ApiController
{
    [HttpPost]
    public async Task<ApiResult<long?>> Create(CreateProductCommand command)
        => CommandResult(await sender.Send(command));

    [HttpGet]
    public async Task<ApiResult<GridData<ProductDto>>> List([FromQuery] string grid)
    {
        var baseGrid = new BaseGrid();
        baseGrid.Set(grid); // hydrate paging/filtering from the JSON query string
        return QueryResult(await sender.Send(new ProductGridQuery(baseGrid)));
    }
}

Every response is a consistent ApiResult with the correct HTTP status code.


Project structure

Despro.Framework.Presentation.Api
├── ControllerTools/            # ApiController base
├── Utilites/                   # RoutePrefixConvention
├── FrameworkPresentationWebDi.cs     # AddFrameworkPresentationWebApi
└── FrameworkPresentationWebUseApp.cs # UseFrameworkPresentationWebApi
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
2.1.1 98 9/8/2026
2.1.0 127 7/18/2026
2.0.9 120 7/2/2026
2.0.8 119 7/2/2026