HTTPClientServiceEx 1.9.0
The HttpClientService package is now deprecated and is no longer maintained. We strongly recommend migrating to the new SmartHttpClient package (version 1.0.0), which offers enhanced features, improved performance, and better support for modern HTTP client use cases.
SmartHttpClient simplifies HTTP interactions by automatically handling JSON serialization/deserialization, managing authentication, and providing a clean, reusable API. It's designed to save developers time and effort while ensuring best practices.
To migrate, update your project references with the SmartHttpClient package:
dotnet add package SmartHttpClient --version 1.0.0
dotnet add package HTTPClientServiceEx --version 1.9.0
NuGet\Install-Package HTTPClientServiceEx -Version 1.9.0
<PackageReference Include="HTTPClientServiceEx" Version="1.9.0" />
<PackageVersion Include="HTTPClientServiceEx" Version="1.9.0" />
<PackageReference Include="HTTPClientServiceEx" />
paket add HTTPClientServiceEx --version 1.9.0
#r "nuget: HTTPClientServiceEx, 1.9.0"
#:package HTTPClientServiceEx@1.9.0
#addin nuget:?package=HTTPClientServiceEx&version=1.9.0
#tool nuget:?package=HTTPClientServiceEx&version=1.9.0
HTTPClientServiceEx
HTTPClientServiceEx is a library for .NET 8.0 that simplifies the use of HttpClient. It provides a reusable, configurable, and extendable way to interact with external APIs or HTTP services.
Installation
Install the package via NuGet:
dotnet add package HTTPClientServiceEx --version 1.9.0
Setup To use this library, you need to register the required services in your Program.cs file.
- Add HTTP Client Services In the Program.cs file of your .NET project, add the following lines:
builder.Services.AddHttpClient(); builder.Services.AddTransient<IHTTPClientWrapper, HTTPClientWrapper>();
- Dependency Injection Example If you're using Dependency Injection in your application (e.g., in a Controller or Service), you can inject the IHTTPClientWrapper like this:
public class MyService { private readonly IHTTPClientWrapper _hTTPClientWrapper; public MyService(IHTTPClientWrapper hTTPClientWrapper) { _hTTPClientWrapper = hTTPClientWrapper; }
// Your methods here
public async Task<T> SendRequestAsync<T>(object requestParam) where T : class
{
var request = new HTTPClientRequest()
{
BaseUri = new Uri($"https://localhost:7081/api/Application"),
Method = HttpMethod.Get,
RequestBody = new { Id = 1 },
EndpointParams = requestParam,
Timeout = TimeSpan.FromSeconds(5),
Authenticator = new Authenticator() { AccessToken = "ABC", Auth = AuthenticationMethod.Bearer },
Headers = new Dictionary<string, string>() { { "api-version", "2" } }
};
return = await _hTTPClientWrapper.SendAsync<T>(request);
}
}
Dependencies Microsoft.Extensions.Http (>= 8.0.1)
Contributing Contributions are welcome! Feel free to submit a pull request or raise an issue in the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.Extensions.Http (>= 8.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.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.9.0 | 229 | 1/16/2025 |
- Added new methods for HTTP GET and POST.
- Fixed bugs with retry policies.
- Improved error handling and logging.