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
<PackageReference Include="Despro.Framework.Presentation" Version="2.10.4" />
<PackageVersion Include="Despro.Framework.Presentation" Version="2.10.4" />
<PackageReference Include="Despro.Framework.Presentation" />
paket add Despro.Framework.Presentation --version 2.10.4
#r "nuget: Despro.Framework.Presentation, 2.10.4"
#:package Despro.Framework.Presentation@2.10.4
#addin nuget:?package=Despro.Framework.Presentation&version=2.10.4
#tool nuget:?package=Despro.Framework.Presentation&version=2.10.4
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>withMetaData(Message,AppStatusCode) — the uniform response shape returned to clients.AppStatusCode— application status enum (Success,NoContent,BadRequest,UnAuthorize,Forbidden,NotFound,InvalidData,ServerError).ModelStateUtil/ModelStateUtilites— flattenModelStateerrors 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 | Versions 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. |
-
net10.0
- Asp.Versioning.Http (>= 10.0.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 10.0.0)
- Despro.Framework.Base (>= 2.1.7)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.9)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 10.0.9)
- Microsoft.AspNetCore.OpenApi (>= 10.0.9)
- Swashbuckle.AspNetCore (>= 10.2.3)
- Swashbuckle.AspNetCore.Swagger (>= 10.2.3)
- Swashbuckle.AspNetCore.SwaggerGen (>= 10.2.3)
- System.IdentityModel.Tokens.Jwt (>= 8.19.1)
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.