Can I use HttpClientFactory in a .NET.core app which is not ASP.NET Core?

前端 未结 4 582
悲&欢浪女
悲&欢浪女 2021-01-07 21:45

I have read the popular blog post https://www.stevejgordon.co.uk/introduction-to-httpclientfactory-aspnetcore on using HttpClientFactory

To quote from it

4条回答
  •  清酒与你
    2021-01-07 22:35

    Thanks for replies.

    So it is possible to use in console app.

    There are a few ways to do this, depending on what way you want to go. Here are 2:

    1. Directly add to ServiceCollection e.g. services.AddHttpClient()

    2. Use Generic host e.g. Add httpclientFactory in .ConfigureServices() method

    See here for blog post using in console app

提交回复
热议问题