Despro.Framework.Presentation 2.10.4

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

Despro.Framework.Presentation

The shared presentation layer of Despro Framework.

Despro.Framework.Presentation contains the HTTP-facing cross-cutting concerns shared by both presentation flavors (Presentation.Api for controllers and Presentation.MinimalApi for minimal endpoints): JWT authentication, Swagger/OpenAPI with API versioning, CORS, HSTS, Mapster configuration, Persian localization, the standardized ApiResult envelope and a global exception-handling middleware.

  • Package: Despro.Framework.Presentation
  • Version: 2.10.1
  • Target framework: net10.0
  • Depends on: Despro.Framework.Base

Installation

dotnet add package Despro.Framework.Presentation

Normally you install one of the concrete flavors (Presentation.Api or Presentation.MinimalApi) which reference this package transitively.

Setup

using Despro.Framework.Presentation;

// ── Service registration ──
builder.Services.AddFrameworkPresentationWeb(
    builder.Configuration,
    ApplicationName: "My Application",
    CorsPolicyName: "DefaultCorsPolicy");

// ── Middleware pipeline ──
var app = builder.Build();
app.UseFrameworkPresentationWeb(ShowSwaggerInProduction: false);

AddFrameworkPresentationWeb wires up JWT authentication, Swagger, Mapster, a named CORS policy (origins from App:CorsOrigins), in-memory caching and HSTS. UseFrameworkPresentationWeb initializes Persian culture, forwarded headers, Swagger UI (dev, or prod when enabled), HTTPS redirection, routing, CORS, auth, static files and the API exception handler.


Key components

Response envelope (ControllerTools)

  • ApiResult / ApiResult<TData> with MetaData (Message, AppStatusCode) — the uniform response shape returned to clients.
  • AppStatusCode — application status enum (Success, NoContent, BadRequest, UnAuthorize, Forbidden, NotFound, InvalidData, ServerError).
  • ModelStateUtil / ModelStateUtilites — flatten ModelState errors into a message.

Status mapping (PresentationApiExtensions)

HttpEnumHelper maps OperationResultStatus → AppStatusCode (MapOperationStatus) and AppStatusCode → typed HTTP results (GetHttpStatusCode), used by both presentation flavors to translate domain results into HTTP responses.

Global exception handling (Middlewares)

ApiExceptionHandlerMiddleware (registered via UseApiExceptionHandler) catches the framework's exception hierarchy (BaseException, BaseForbiddenException, BaseInvalidDataException, BaseNotFoundException), maps each to the right AppStatusCode, logs via IErrorLogger, and writes a JSON ApiResult.

Utilities (Utilites)

Helper Purpose
AddJwtAuthentication JWT bearer auth from JwtConfig:*; validates issuer/audience/lifetime/signing key with zero clock skew; also accepts a token via the access_token query string.
AddSwagger API versioning (UrlSegmentApiVersionReader, 'v'VVV format) + Swagger with a Bearer security scheme.
ConfigureSwaggerOptions Builds a Swagger doc per discovered API version.
AddMapsterConfig Registers IMapper and global DateTime ⇄ long (Ticks) mappings.
DatePersian Initializes the fa-IR Persian (Jalali) culture.

Configuration

Key Used by Notes
JwtConfig:SignInKey AddJwtAuthentication Symmetric signing key (UTF-8).
JwtConfig:Issuer AddJwtAuthentication Validated issuer.
JwtConfig:Audience AddJwtAuthentication Validated audience.
App:CorsOrigins AddFrameworkPresentationWeb Comma-separated allowed origins (throws if empty).

Project structure

Despro.Framework.Presentation
├── ControllerTools/            # ApiResult, AppStatusCode, ModelState helpers
├── Middlewares/                # ApiExceptionHandlerMiddleware
├── PresentationApiExtensions/  # HttpEnumHelper (status mapping)
├── PresentationExceptions/     # BasePresentationException
├── Utilites/                   # JWT, Swagger, Mapster, Persian culture
├── FrameworkPresentationWebDi.cs     # AddFrameworkPresentationWeb
└── FrameworkPresentationWebUseApp.cs # UseFrameworkPresentationWeb
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 (2)

Showing the top 2 NuGet packages that depend on Despro.Framework.Presentation:

Package Downloads
Despro.Framework.Presentation.Api

Presentation Api Framework For Despro

Despro.Framework.Presentation.MinimalApi

Presentation MinimalApi Framework For Despro

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.10.4 116 9/8/2026
2.10.3 152 7/18/2026
2.10.2 142 7/2/2026
2.10.1 140 7/2/2026