175 questions
0
votes
2
answers
110
views
Add individual certificate to HttpClient created via HttpClientFactory
I do have a .NET 8.0 web application using HttpClient to send requests to different vendors. To get the HttpClient objects, I'm using the IHttpClientFactory interface installed via AddHttpClient ...
2
votes
3
answers
211
views
.NET 8, HttpClient and File Uploads: what am I missing? Creating request with headers and Query Params
Here's a .NET 4.6.2 API web client uploading a file - simple stuff:
var webClient = new ApiWebClient();
webClient.Timeout = timeout;
webClient.Headers.Add( HttpHeaderNames.CONTENT_TYPE, contentType );...
0
votes
2
answers
627
views
.NET Core : efficiency of using multiple HttpClientFactory instances
I am developing a simple ASP.NET Core Web API which redirects its calls to different APIs (heavy load).
All of the APIs I call have the same settings, just different URIs.
The code logic determines ...
1
vote
1
answer
78
views
How to resolve unknown differences between new HttpClient instance and HttpClientFactory instance
Currenty I'm building a solution which is basically an integration between multiple external REST services. Since the solution is having multiple external service, I want to use the .NET ClientFactory ...
1
vote
1
answer
861
views
Proper use of HttpClientFactory for large amount of concurrent requests
I have a .NET Core 8 project where i need to send large amount of concurrent request as fast as possible to a SOAP webservice. I am experiencing long responsetime when creating new HttpClient per ...
1
vote
1
answer
98
views
.NET: Is there an existing dependency-injection method for setting up cookies for an HttpClient/HttpClientFactory?
I have lots of HttpClient dependency-injected services. I use an HttpClientFactory to get these.
There are variations, but in a simple case:
// Configure a named and configured HTTP client called &...
1
vote
1
answer
400
views
When I mock IHttpClientFactory and create a HttpClient, HttpClient is null
I would like to unit test a factory in which I inject IHttpClientFactory and this factory create a class that uses a HttpClient.
This is the code:
public class ClientFactory : IClientFactory
{
...
3
votes
1
answer
261
views
When IHttpClientFactory close TCP connection internally?
based on the article https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
// in startup.cs
...
1
vote
1
answer
849
views
Why I have too many established socket connection during high traffic with using HttpClientFactory in Azure function
I have Azure function app on dedicated premium App service plan. Function in one execution has to delivery two times some data to one api's endpoint.
For sending data, I use http client which is ...
0
votes
1
answer
2k
views
Maui: AddHttpClient and AddSingleton outside of CreateMauiApp
I'm migrating an app from Xamarin Forms using Prism and DryIoc to Maui and need to register a service and HttpClientFactory outside of the CreateMauiApp function (Reason being I don't know the endpint ...
-1
votes
1
answer
928
views
Add Certificates to HTTP Client using Azure Key Vault and IHTTPClientFactory in FunctionApps
EDIT: This code does work. I had the wrong value in the Entity List Environment Variable
I've been trying to add certificates to the HTTP client factory using dependency injection. I will need to ...
-1
votes
1
answer
927
views
Using HttpClientFactory in webAPI controller (.NET core 6 ) [closed]
I'm wondering if my implementation in my webAPI is correct:
Startup.cs => ConfigureServices
services.AddHttpClient("MyHttpClient")
Startup.cs => Configure
applicationLifetime....
0
votes
1
answer
208
views
How to get bulk reports via Twilio API?
I'm going to get reports over call/message on Twilio via API. They have a limitation of 1000 reports on a single page. The requested GET query is something like this https://api.twilio.com/2010-04-01/...
1
vote
2
answers
2k
views
Getting issue while using HttpClient/HttpClientFactory in .net core
We have implemented IHttpClientFactory to make the third party calls using HttpClient in .NET Core. However, we are still getting the below errors.
System.IO.IOException: Unable to read data from the ...
-1
votes
1
answer
681
views
Polly FallbackPolicy with Refit and HttpClientFactory
I use the HttpClientFactory together with Refit to make API calls. I want to use Polly for Retry, Circuit Breaker and Fallback, and while it's easy to set up Retry and Circuit Breaker, I struggle with ...
0
votes
0
answers
743
views
Passing Parameters dynamically to HttpClient based on the request
I have a .NET standard 2.0 class library which is responsible for making all the HttpClient calls from the applications that consume the library.
With all the understanding from the Microsoft ...
1
vote
1
answer
907
views
HttpClientFactory throws an error on client setup
How is it possible that I get this error message in the setup of a client when I use HttpClientFactory? Who is already using this client?
I've been trying both like this as a named client and also by ...
0
votes
2
answers
1k
views
Do I need to add all HttpClients?
If I use _httpClientFactory.CreateClient() in a singleton (no name for the client, I set it up when I use it)
Should I add/specify an empty services.AddHttpClient(); at startup or is that not ...
0
votes
1
answer
156
views
Can you create HttpClient read-only property and re-use it in your methods?
Is there any issue with below implementation inside Blazor component? A lot of examples repeatedly use CreateClient inside every method and I am wondering if it can be handled by a property, in one ...
0
votes
1
answer
285
views
Sync data from remote api and save it to my localdb
I want to sync data from remote api! something like 1M record! but the whole process talks about 5Mins.
as a user experience, that's very bad thing to do! I want the whole process takes less than 1S!
...
0
votes
1
answer
324
views
Do I need to create a new HttpClient for subsequent requests to new BaseAddress?
Take for example the following, I use a single httpClient, assign the BaseAddress, and then pass it to the client that will ultimately use it:
var httpClient = httpClientFactory.CreateClient("...
2
votes
3
answers
2k
views
Nunit 3: Test a Controller that uses IHttpClientFactory as Constructor Parameter
Update 20221024: I have used Ruikai Feng's solution in order to use Mockoon with my tests. I realize this is not a correct approach from a unit testing approach and am working to change my approach.
...
3
votes
1
answer
4k
views
Cannot get Polly retry Http calls when given exceptions are raised
My service definition:
var host = new HostBuilder().ConfigureServices(services =>
{
services
.AddHttpClient<Downloader>()
.AddPolicyHandler((services, request) =>
...
11
votes
1
answer
5k
views
What is the lifetime of a typed HttpClient instance from IHttpClientFactory where the type that will receive it is registered as "AddScoped"?
TL;DR
In .NET 6:
What is the lifetime of a typed HttpClient instance from IHttpClientFactory where the type that will receive it is registered as "Scoped"?
Shouldn't it be kind of a "...
3
votes
0
answers
4k
views
In .NET 6 Core, how can I create a HttpClient using the HttpClientFactory with a HttpClientHandler?
I have the below code that I wish to transfer over to a .NET 6 Core.
HttpClientHandler handler = new HttpClientHandler();
HttpClient client = new HttpClient(handler);
CookieContainer cookieContainer = ...