General.Frontend.Shared
3.0.2
See the version list below for details.
dotnet add package General.Frontend.Shared --version 3.0.2
NuGet\Install-Package General.Frontend.Shared -Version 3.0.2
<PackageReference Include="General.Frontend.Shared" Version="3.0.2" />
<PackageVersion Include="General.Frontend.Shared" Version="3.0.2" />
<PackageReference Include="General.Frontend.Shared" />
paket add General.Frontend.Shared --version 3.0.2
#r "nuget: General.Frontend.Shared, 3.0.2"
#:package General.Frontend.Shared@3.0.2
#addin nuget:?package=General.Frontend.Shared&version=3.0.2
#tool nuget:?package=General.Frontend.Shared&version=3.0.2
Generic API Client
Reusable .NET client infrastructure for consuming ASP.NET Core APIs through HttpClient.
The package depends on the Generic Backend package for shared API contracts and data models. It does not duplicate those types. Its responsibility is the client-side HTTP infrastructure and generic API repository implementation.
Features
- Generic
IGenericAPIRepository<TResponse, TRequest>contract - Reusable
GenericAPIRepository<TResponse, TRequest>implementation - GET by identifier
- Paginated GET
- HTTP
QUERYfor dynamic filtering - POST create
- PUT update
ResponseService<T>andQueryResult<T>support- Bearer token support
- Cancellation token propagation
- Dependency-injection friendly design
- UI agnostic
Architecture
Application / UI
|
v
IGenericAPIRepository<TResponse,TRequest>
^
|
GenericAPIRepository<TResponse,TRequest>
|
v
HttpClient
|
v
ASP.NET Core API
The application depends on the repository contract while the generic implementation handles HTTP transport.
Quick Start
Create a resource-specific repository:
public sealed class ActivityAPIRepository(HttpClient httpClient)
: GenericAPIRepository<ActivityDto, ActivityCreationDto>(
httpClient,
"activity",
"api")
{
}
Register the abstraction:
services.AddScoped<
IGenericAPIRepository<ActivityDto, ActivityCreationDto>,
ActivityAPIRepository>();
Consume it through the interface:
public sealed class ActivityService(
IGenericAPIRepository<ActivityDto, ActivityCreationDto> repository)
{
public Task<ResponseService<ActivityDto>> GetAsync(
int id,
CancellationToken cancellationToken = default)
{
return repository.GetByIdAsync(id, cancellationToken);
}
}
Endpoints
GET /api/activity/{id}
GET /api/activity?page=1&recordsByPage=20
QUERY /api/activity/dynamic-filter
POST /api/activity
PUT /api/activity/{id}
Dynamic Query
var request = new QueryRequest(
new RequestPagination(1, 20),
filters);
var response = await repository.QueryAsync(
request,
cancellationToken);
Documentation
Design Principles
- Contract-first: applications depend on
IGenericAPIRepository. - Generic transport: HTTP construction and JSON serialization are centralized.
- DTO-based communication: the client does not require backend persistence entities.
- Query metadata preservation:
QueryResult<T>contains records and total count. - Cancellation propagation: tokens flow to
HttpClient. - UI agnostic: no dependency on Blazor, Radzen, or another UI framework.
| 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
- General.Contracts.Shared (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
refactor: fix thread safety, security, and correctness issues in GenericAPIRepository
- Replace DefaultRequestHeaders mutation with per-request Authorization header via
HttpRequestMessage, making SetToken/RemoveToken thread-safe
- Fix Bearer token casing (bearer -> Bearer, per RFC 6750)
- Add EnsureSuccessStatusCode() before deserializing responses in all HTTP methods,
preventing JsonException on HTML error pages (401, 502, etc.)
- Fix GetByIdAsync error reporting wrong service name ("GetAllAsync")
- Remove unused System.Runtime.InteropServices.Marshalling using
- IGenericAPIRepository: remove empty outer wrapper interface; promote generic interface
to top level
- GridUtils.SetEntityValues: fix null/type handling with Convert.ChangeType to prevent
InvalidCastException on non-string properties
- GridUtils: remove Console.WriteLine and dead try/catch blocks
- Add GeneratePackageOnBuild to .csproj for consistency with backend project
- Update General.Backend.Shared library
- Refactor change Dinamic by Dynamic
-()26/08/2026 Decoupling shared elements between the front end and the back endbeackendGeneral.B libaryr