Legal Notice
The opinions expressed herein are my own personal opinions and do not represent my employer’s view in anyway.Top Posts
- C# DateTime to UNIX timestamps
- C# JWT Token Get Expiry Timestamp
- .NET API CORS: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header.NET API
- C# Azure Table Storage QueryAsync, Paging and Filtering
- C# Calculate Week Number from DateTime
- C# Use HttpClient to GET JSON from API endpoint
- C# get results from Task.WhenAll
Archive
Meta
Tag Archives: IHttpClientFactory
C# Use HttpClient to GET JSON from API endpoint
So, most API endpoints return JSON anyway, right? So why not make a method that can make a GET call to an API and return the response as an object directly? It’s actually not that hard: STEP 1: MAKE A … Continue reading
Posted in .net, .NET Core, c#, General .NET
Tagged Asynchronous, generics, Http, HttpClient, IHttpClientFactory, JSON
Leave a comment
C# HttpClient and IHttpClientFactory in .net core
The C# HttpClient is the go-to library when you need to GET, PUT, POST or DELETE from an API Endpoint. But one of the issues with HttpClient is that it needs to be instantiated as a singleton. This is a … Continue reading
Posted in .net, .NET Core, c#, General .NET
Tagged Asynchronous, Await, HttpClient, IHttpClientFactory, Static
2 Comments
Get Users from IdentityServer using .NET Core
If you wish to poke around in the IdentityServer users database directly, the API seems a little bit fishy. This is because the direct data access are very low level, and consists of HttpClient extension methods. They are, in fact, … Continue reading
Posted in .net, .NET Core, c#, General .NET
Tagged Authentication, Authorization, HttpClient, IdentityServer, IHttpClientFactory, JWT
Leave a comment
HttpClient retry on HTTP timeout with Polly and IHttpClientBuilder
The Polly retry library and the IHttpClientBuilder is a match made in heaven as it defines all the retry logic at startup. The actual HttpClient calls are therefore untouched by any retry code. The retry logic is called policies, and … Continue reading
Posted in .net, .NET Core, c#
Tagged HttpClient, IHttpClientBuilder, IHttpClientFactory, Polly
5 Comments
Add a UserAgent to the IHttpClientFactory in .NET Core
Using a IHttpClientFactory to create HttpClient connections have a number of advantages, as you can configure several httpclients on startup. Each client will be reused, including the properties attached to that client. In a previous post I showed how to … Continue reading
HttpClient retry mechanism with .NET Core, Polly and IHttpClientFactory
A lot of HttpClient errors are temporary and is caused by server overload, temporary nerwork timeouts and generic gliches in the Matrix. These scenarios can be dealt with using a retry pattern. In .NET Core, the most common retry library … Continue reading