AsNet.Shared.Http
1.2.1.1
See the version list below for details.
dotnet add package AsNet.Shared.Http --version 1.2.1.1
NuGet\Install-Package AsNet.Shared.Http -Version 1.2.1.1
<PackageReference Include="AsNet.Shared.Http" Version="1.2.1.1" />
<PackageVersion Include="AsNet.Shared.Http" Version="1.2.1.1" />
<PackageReference Include="AsNet.Shared.Http" />
paket add AsNet.Shared.Http --version 1.2.1.1
#r "nuget: AsNet.Shared.Http, 1.2.1.1"
#:package AsNet.Shared.Http@1.2.1.1
#addin nuget:?package=AsNet.Shared.Http&version=1.2.1.1
#tool nuget:?package=AsNet.Shared.Http&version=1.2.1.1
AsNet.Shared.Http
A shared, enterprise‑grade HTTP infrastructure library for .NET that simplifies API consumption, supports high‑performance streaming, and provides built‑in OAuth2 / OpenID Connect integration (IdentityServer ready).
Features
- Generic, strongly‑typed HTTP API client abstraction.
- Full HTTP verb support: GET, POST, PUT, DELETE.
- Sync and async APIs.
- High‑performance streaming using
IAsyncEnumerable<T>. - Advanced error handling with rich metadata (
ApiEx). - Built‑in JSON serialization configuration with custom converters.
- Integration with HttpClientFactory.
- Centralized configuration via
appsettings.json. - OAuth2 / OpenID Connect token management (IdentityServer compatible).
- Pluggable token providers (Strategy pattern).
- Ready‑to‑use IPStack geolocation service.
- SQL Server Reporting Services (SSRS) helpers.
- Multi‑framework support.
Typical Use Cases
- Enterprise microservices communication
- High‑performance API consumption
- Streaming large datasets
- Accessing secured APIs with OAuth2 / OIDC
- IP geolocation services
- SSRS report execution and management
- Shared HTTP infrastructure libraries
Supported Frameworks
- .NET Standard 2.1
- .NET 6
- .NET 7
- .NET 8
- .NET 9 / .NET 10 (forward compatible)
The same API surface and development experience are preserved across all runtimes.
Core Components
HTTP API Services
IApiService<T>(for .NET 6+)IApiServiceNetStandard<T>(for .NET Standard 2.1)
Provides:
- Typed HTTP requests and responses
- Tuple‑based results
(Result, HttpResponseMessage, ApiEx) - Byte array downloads
- GET and DELETE with body support
- Configurable timeout and JSON serialization
Streaming APIs
Efficient processing of large responses using:
IAsyncEnumerable<T>- Incremental JSON deserialization
ResponseHeadersRead
Available methods:
GetAsyncEnumerablePostAsyncEnumerableGetFromJsonAsyncEnumerable(NET 8+)
JSON Serialization
- Based on
System.Text.Json - Extended with
Dahomey.Json - Includes custom converters:
TimeSpanJsonConverter
Default configuration supports:
- Case‑insensitive properties
- Trailing commas
- Comments
- Optimized buffers
Error Handling
HTTP errors are transformed into structured exceptions:
- HTTP status and response propagation
- Automatic parsing of validation errors (
ModelState) - Dynamic error payload extraction
- Rich diagnostic data via
Exception.Data
Security & Authentication
OAuth2 / OpenID Connect
Includes a flexible token service designed for secured APIs and compatible with multiple OAuth2 / OpenID Connect providers.
Supported providers include:
- Duende IdentityServer
- IdentityServer4
- Azure AD / Microsoft Entra ID
- Keycloak
- Auth0
- Custom OAuth2/OpenID Connect providers
The token infrastructure follows a provider-based architecture that enables a single application, microservice or integration process to authenticate against multiple authorization servers simultaneously.
This design is especially useful for:
- Multi-tenant SaaS solutions
- Enterprise integrations
- Customer-specific APIs
- Third-party secured services
- Hybrid authentication environments
Supported Grant Types
- Client Credentials
- Authorization Code
- Password
- On‑Behalf‑Of (OBO)
- Token Exchange
Key Types
ITokenServiceITokenProviderIOAuthProviderResolverOAuthProviderResolverTokenServiceTokenRequestContextOAuthProviderSettings
Built‑in providers:
ClientCredentialsTokenProviderAuthorizationCodeTokenProvider
Token providers are selected automatically according to the requested GrantType.
OAuth provider configuration is resolved independently, allowing the same application to work with multiple OAuth servers without code changes.
Provider Resolution
When requesting an access token, provider configuration is resolved using the following precedence order:
- ProviderSettings (runtime override)
- ProviderName (named provider)
- Default provider configuration
This allows the library to support:
- Static application authentication
- Multiple configured OAuth providers
- Customer-specific integrations
- Runtime configuration loaded from databases
- Fully dynamic multi-tenant environments
IPStack Integration
Includes a ready‑to‑use IP geolocation service:
IPStackService(NET 6+)IPStackServiceNetStandard
Features:
- IP‑based geolocation lookup
- Standardized result wrapping
- Integrated error handling
- Configuration via
HttpSettings
SQL Server Reporting Services (SSRS)
Helpers for SSRS integration:
- Report execution and export
- Report catalog navigation
- Parameter discovery
- Support for SSRS 2005 and 2010+
Supported export formats:
- PDF, Excel, Word, XML, CSV, HTML, MHTML, Image
Required Configuration
HTTP Settings
"AsNet": {
"Http": {
"HttpSettings": {
"HandlerLifetime": "00:05:00",
"Timeout": "00:02:00",
"DefaultClientName": "AsNetSharedHttp",
"IPStackURL": "http://api.ipstack.com",
"IPStackAccessKey": "<your-api-key>"
}
}
}
### OAuth Provider Settings
The library supports a default OAuth provider and any number of named
providers.
Example:
```json
{
"AsNet": {
"Security": {
"IdentityServerSettings": {
"Default": {
"Address": "https://sso.company.com",
"ClientId": "default-client",
"ClientSecret": "secret",
"Scope": "api"
},
"Providers": {
"AsNet": {
"Address": "https://sso.company.com",
"ClientId": "client1",
"ClientSecret": "secret1",
"Scope": "api"
},
"CustomerA": {
"Address": "https://auth.customera.com",
"ClientId": "client2",
"ClientSecret": "secret2",
"Scope": "documents"
},
"CustomerB": {
"Address": "https://login.customerb.com",
"ClientId": "client3",
"ClientSecret": "secret3",
"Scope": "files"
}
}
}
}
}
}
### Token Request Examples
#### Default Provider
Uses the default configured OAuth provider.
```csharp
var token = await tokenService.GetAccessTokenAsync(
new TokenRequestContext
{
GrantType = TokenGrantType.ClientCredentials
});
Named Provider
Uses a specific provider defined in configuration.
var token = await tokenService.GetAccessTokenAsync(
new TokenRequestContext
{
GrantType = TokenGrantType.ClientCredentials,
ProviderName = "CustomerA"
});
Runtime Provider Override
Uses a dynamically supplied provider configuration.
var token = await tokenService.GetAccessTokenAsync(
new TokenRequestContext
{
GrantType = TokenGrantType.ClientCredentials,
ProviderSettings = new OAuthProviderSettings
{
Address = "https://auth.customer.com",
ClientId = "customer-client",
ClientSecret = "secret",
Scope = "api"
}
});
Typical scenarios:
- Customer-specific API integrations
- Multi-tenant SaaS platforms
- OAuth settings stored in databases
- Dynamic runtime authentication ``
Multi-Provider Integration Scenario
A single application can authenticate against different OAuth providers using the same token infrastructure.
Example:
// Internal AsNet API
var asNetToken = await tokenService.GetAccessTokenAsync(
new TokenRequestContext
{
GrantType = TokenGrantType.ClientCredentials,
ProviderName = "AsNet"
});
// Customer API
var customerToken = await tokenService.GetAccessTokenAsync(
new TokenRequestContext
{
GrantType = TokenGrantType.ClientCredentials,
ProviderName = "CustomerA"
});
// Third-party API
var externalToken = await tokenService.GetAccessTokenAsync(
new TokenRequestContext
{
GrantType = TokenGrantType.ClientCredentials,
ProviderName = "CustomerB"
});
Each provider maintains its own authentication configuration and token cache, allowing secure and efficient communication with multiple protected APIs from within the same process.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- AsNet.Shared (>= 3.2.0.4)
- Dahomey.Cbor (>= 1.26.3)
- Dahomey.Json (>= 1.12.2)
- Duende.IdentityModel (>= 8.1.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- System.Formats.Asn1 (>= 10.0.9)
- System.Security.Cryptography.Pkcs (>= 10.0.9)
- System.Security.Cryptography.Xml (>= 10.0.9)
- System.ServiceModel.Http (>= 8.1.2)
-
net10.0
- AsNet.Shared (>= 3.2.0.4)
- Dahomey.Cbor (>= 1.26.3)
- Dahomey.Json (>= 1.12.2)
- Duende.IdentityModel (>= 8.1.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- System.Security.Cryptography.Pkcs (>= 10.0.9)
- System.Security.Cryptography.Xml (>= 10.0.9)
- System.ServiceModel.Http (>= 10.0.652802)
-
net8.0
- AsNet.Shared (>= 3.2.0.4)
- Dahomey.Cbor (>= 1.26.3)
- Dahomey.Json (>= 1.12.2)
- Duende.IdentityModel (>= 8.1.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- System.Formats.Asn1 (>= 10.0.9)
- System.Security.Cryptography.Pkcs (>= 10.0.9)
- System.Security.Cryptography.Xml (>= 10.0.9)
- System.ServiceModel.Http (>= 8.1.2)
-
net9.0
- AsNet.Shared (>= 3.2.0.4)
- Dahomey.Cbor (>= 1.26.3)
- Dahomey.Json (>= 1.12.2)
- Duende.IdentityModel (>= 8.1.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- System.Formats.Asn1 (>= 10.0.9)
- System.Security.Cryptography.Pkcs (>= 10.0.9)
- System.Security.Cryptography.Xml (>= 10.0.9)
- System.ServiceModel.Http (>= 8.1.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AsNet.Shared.Http:
| Package | Downloads |
|---|---|
|
AsNet.Shared.Data
Enterprise‑grade multi‑tenant data infrastructure library for .NET that provides secure integration with AsNetSecurity, dynamic connection string resolution per tenant, and generic data access components built on Entity Framework Core. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.2.1.2 | 120 | 9/11/2026 | |
| 1.2.1.1 | 262 | 7/9/2026 | |
| 1.2.1 | 160 | 7/6/2026 | |
| 1.2.0.4 | 526 | 5/6/2026 | |
| 1.2.0.3 | 271 | 4/7/2026 | |
| 1.2.0.2 | 168 | 4/6/2026 | |
| 1.2.0.1 | 194 | 2/8/2026 | |
| 1.2.0 | 219 | 1/13/2026 | |
| 1.1.2 | 332 | 6/30/2025 | |
| 1.1.1 | 357 | 1/6/2025 | |
| 1.1.0.5 | 309 | 12/9/2024 | |
| 1.1.0.4 | 315 | 12/9/2024 | |
| 1.1.0.3 | 323 | 11/11/2024 | |
| 1.1.0.2 | 361 | 9/6/2024 | |
| 1.1.0.1 | 321 | 6/20/2024 | |
| 1.1.0 | 316 | 6/9/2024 | |
| 1.0.7.1 | 448 | 9/29/2023 | |
| 1.0.7 | 284 | 9/28/2023 | |
| 1.0.6.10 | 290 | 9/23/2023 | |
| 1.0.6.8 | 289 | 9/23/2023 |
• Optimized and customized JSON serialization using System.Text.Json and Dahomey.Json.
• Improved overall HTTP client performance.
• Added Dependency Injection (DI) ready services for Web API consumption.
• Introduced TimeSpanJsonConverter to properly support TimeSpan properties with System.Text.Json.
• Multi‑framework support: .NET Standard 2.1, .NET 8.0, .NET 9.0, and .NET 10.0.
• Enhanced async methods to return a Tuple (T, HttpResponseMessage, ApiException) for improved diagnostics.
• Added GET and DELETE methods with BodyRequest support.
• Added GetByteArray and GetByteArrayAsync methods for binary content retrieval.
• Added streaming methods: GetAsyncEnumerable, PostAsyncEnumerable, and GetFromJsonAsyncEnumerable.
• Streaming APIs return IAsyncEnumerable<T>, enabling higher performance and memory‑efficient data processing.