An alternative approach to dynamically updating request headers on an HttpClient generated by HttpClientFactory in ASP.NET Core. Using the lesser-known ConfigureHttpClient extension method on HttpClientBuilder, you can pass an Action that receives both the ServiceProvider and the HttpClient, allowing you to resolve services (like a TokenGenerator) and inject dynamic values into request headers at configuration time — simpler than the DI-based approach covered in a previous post.

1m read timeFrom nodogmablog.bryanhogan.net
Post cover image