Skip to content

Document guidance about when to use and not use HTTP Client Factory #11882

Open

Description

@rynowak

We should improve the scenario guidance around HTTP client to help users understand the whens and whys of choosing to use the HTTP Client Factory.

I want a section of the doc that provides clear messaging around the topics raised by a question like: https://github.com/aspnet/Extensions/issues/1345 Users often feel like they want to use something like the HTTP Client Factory but also don't want to use the actual HTTP Client Factory, so they ask us to change it so they have more alternatives.

We should also include samples and guidance for using HTTP Client Factory and other Microsoft.Extensions libraries outside of ASP.NET Core. Example using Web Forms: https://github.com/glennc/httpclientfactorysample/blob/master/src/WebUI.WebForms/Global.asax.cs#L26 It's not clear to users that this is possible, and it is actually something we recommend.

Using the Microsoft.Extensions libraries outside of ASP.NET Core is a great way to start modernizing an older application, and has resonated really well with some users I have talked to about it.

Activity

  1. changed the title [-]Document guidance about HTTP Client Factory[/-] [+]Document guidance about when to use and not use HTTP Client Factory[/+] on Apr 7, 2019
  2. added this to the Backlog milestone on Apr 9, 2019
  3. ericsampson commented on Oct 24, 2019

    @ericsampson

    Thanks Ryan. It would also be helpful to have documentation on how to incorporate HttpClientFactory with alternate IoC Container providers like autofac and Castle Windor.

  4. SridharPasham commented on Oct 25, 2019

    @SridharPasham

    Thanks @rynowak I was looking for the usage of HttpClientFactory without startup class. The link which you provided for Global.asax helped me. Thanks.

  5. changhuixu commented on Mar 26, 2020

    @changhuixu

    Hi, I followed the issue https://github.com/dotnet/extensions/issues/1345 to here.
    I am curious about how does Azure key vault work when we add it as a configuration provider during the ConfigureAppConfiguration stage. So I took a look at the source code for AzureSDK.

    Azure SDK has a concept, HttpPipeline, which represents a primitive for sending HTTP requests and receiving responses.
    https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core/src/Pipeline/HttpPipeline.cs

    Is the HttpPipeline a sibling of the HttpClient? Does .NET have something similar to the HttpPipeline that is primitive and can be used during the generic host build stage?

    Thank you.

  6. mnoreen commented on Sep 23, 2020

    @mnoreen

    I would like to see guidance, recommended code for using HttpClient in Web Forms. Not asp.net on .net core, not MVC... ASP.NET Web Forms. Fair to expect a web forms website to be running on latest framework (e.g. 4.8). Assume there is no added on dependency injection system. How to properly instantiate HttpClient and use it w/out "exhausting sockets" issue?

  7. daiplusplus commented on Jan 22, 2021

    @daiplusplus

    @mnoreen If it helps, I wrote this to make it easy to use MEDI in WebForms: https://github.com/Jehoel/AspNetDependencyInjection - I use it with IHttpClientFactory without problems.

  8. mnoreen commented on Jan 22, 2021

    @mnoreen

    @Jehoel Thank you! I hope to experiment w/ your WebForms DI project. And your write up is of particular interest. We have a very mature, 10+ year asp.net webforms solution, still going strong (current on the full Framework 4.8). But... we are trying to figure out how to bridge over to .NET core (or just the "new" .NET), pretty much exactly as you write. We'd like to spin up side by side websites, but there's just a whole of truly fundamental things to contend with... authentication being one of the most significant bits (as in how to use the same auth cookie in a side by side website scenario)! We have many base pages that .aspx pages inherit from, we have dozens of our own server controls and dozens more user controls. Would love to hear more about your experiences.

  9. daiplusplus commented on Jan 23, 2021

    @daiplusplus

    @mnoreen Sure, I'll be happy to. Please create a new discussion in that repo so we don't detail this thread: https://github.com/Jehoel/AspNetDependencyInjection/discussions

  10. tudor-turcu commented on May 6, 2022

    @tudor-turcu

    @rynowak Any updates on this issue?
    I'm also searching for a guidance on how to best use HttpClient, in an ASP.NET MVC 5 application (.NET Framework 4.7), without a DI framework and without taking a dependency on Microsoft.Extensions.DependencyInjection or Microsoft.Extensions.Hosting

  11. added
    re-Aditya
    and removed on Sep 29, 2022
  12. self-assigned this
    on Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Pri1doc-enhancementre-Aditya

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions