skip to Main Content

Asp.net – How to use "TypedHttpClientFactory" with "AddHttpMessageHandler"?

I have some AuthorizationHandler that I register with a typed client: var clientFactory = services.BuildServiceProvider().GetRequiredService<IHttpClientFactory>(); services.AddHttpClient<TypedClient>() .AddHttpMessageHandler(() => { var authorization = new BearerAuthorization(clientFactory, clientId, clientSecret, authHost, token); return new AuthorizationHandler(authorization); }); When I get the "TypedClient" directly through the…

VIEW QUESTION

Visual Studio Code – Exception is always thrown by httpClient.PostAsync. I can temporarily get past it with ConfigureAwait(false) but I can't avoid an exception completely

I am doing Async and Await with C# ASP.Net MVC, with Target .Net Framework 4.8 using Visual Studio 2022. So no matter what, I always get an exception when I call httpClient.PostAsync(...). I can call httpClient.PostAsync(...).ConfigureAwait(false) which doesn't give me…

VIEW QUESTION

Asp.net – Polly Retry with HTTP Client is exceeding the Number of Max Retries and continues Retry till HTTP Timeout Occurred

I have defined some Typed API Client via Dependency Injection in Start up like below. public void ConfigureHttpClients(IServiceCollection services) { services.AddHttpClient<IMyHttpClient,MyHttpClient>() .AddPolicyHandler(GetRetryPolicy(Configuration)); } And Get Retry Policy is defined like this : private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy(IConfiguration configuration) { int numberOfretries…

VIEW QUESTION
Back To Top
Search