https://github.com/konak/am.kon.packages.services.web-client-service
The WebClientService package provides a robust and flexible web client component designed to be used as a service within .NET Core applications. It leverages the power of 'IHttpClientFactory' to facilitate efficient and scalable interactions with web services.
https://github.com/konak/am.kon.packages.services.web-client-service
ihttpclientfactory webclient
Last synced: 11 months ago
JSON representation
The WebClientService package provides a robust and flexible web client component designed to be used as a service within .NET Core applications. It leverages the power of 'IHttpClientFactory' to facilitate efficient and scalable interactions with web services.
- Host: GitHub
- URL: https://github.com/konak/am.kon.packages.services.web-client-service
- Owner: konak
- Created: 2023-02-04T14:09:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-01T18:04:02.000Z (about 1 year ago)
- Last Synced: 2025-06-02T03:38:03.726Z (about 1 year ago)
- Topics: ihttpclientfactory, webclient
- Language: C#
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/konak/am.kon.packages.services.web-client-service/actions/workflows/dotnet.yml)
# WebClientService for .NET Core
The WebClientService package provides a robust and flexible web client component designed to be used as a service within .NET Core applications. It leverages the power of '**IHttpClientFactory**' to facilitate efficient and scalable interactions with web services. This package supports dependency injection, making it easy to integrate into your existing .NET Core applications.
## Key Features:
- **Dependency Injection**: Seamlessly integrates with the .NET Core dependency injection framework.
- **HTTP Client Management**: Utilizes '**IHttpClientFactory**' for robust HTTP client instantiation and management.
- **Result Handling**: Comprehensive handling of HTTP response results with detailed status and error information.
- **Extensible Base Classes**: Abstract base classes for implementing services that interact with web endpoints, returning various data types including strings and streams.
- **Configurable Requests**: Supports various HTTP methods, custom headers, bearer token authentication, and more.
## Usage Scenarios:
- Consuming RESTful APIs
- Fetching data from web services
- Handling HTTP responses with rich error information
- Streaming data from endpoints
## Getting Started:
1. **Installation**: Install the package via NuGet Package Manager.
```shell
dotnet add package WebClientService
```
2. **Configuration**: Configure IHttpClientFactory in your Startup.cs.
```C#
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddScoped();
services.AddScoped();
}
```
3. **Usage**: Inject the service into your controllers or services and start making web requests.
```C#
public class MyService
{
private readonly WebClientStringDataService _webClient;
public MyService(WebClientStringDataService webClient)
{
_webClient = webClient;
}
public async Task GetDataAsync(Uri requestUri)
{
var result = await _webClient.InvokeRequest(requestUri);
if (result.Result == RequestInvocationResultTypes.Ok)
{
return result.Data;
}
else
{
// Handle error
throw new Exception(result.Message);
}
}
}
```