Use HttpClient Properly with HttpClientFactory With Named and Typed Clients in .NET

Sdílet
Vložit
  • čas přidán 11. 03. 2024
  • ►► Master Web API development Best Practices: bit.ly/3TnqoFQ
    ►► Build great web apps in Blazor WebAssembly: bit.ly/437g87T
    ►► Support us on Patreon and get the source code: / codemaze
    In this video, I will show you how to properly use an HttpClient in your application by using an HttpClientFactory. You will see the advantages of using HttpClientFactory and how it prevents additional problems that HttpClient can cause. Additionally, I will show you how to create named and typed clients using HttpClientFactory.
    FOLLOW US ON SOCIAL MEDIA!
    ►► / marinko-spasojevic
    ►► / codemazeblog
    ►► / codemazeblog

Komentáře • 13

  • @CodeMaze
    @CodeMaze  Před 2 měsíci

    Thank you all for watching and for your support.
    ►► If you want to master Web API development using best practices, check out our Web API book: bit.ly/3x75ZMM
    ►► Also, to build great full-stack apps with Blazor, check out our course: bit.ly/3Pw3Y33

  • @StefanLeshi
    @StefanLeshi Před 2 měsíci

    Great video

    • @CodeMaze
      @CodeMaze  Před 2 měsíci

      Glad you enjoyed it

    • @StefanLeshi
      @StefanLeshi Před 2 měsíci

      @@CodeMaze i was curently workimg with http client and was looking how to optimize it so yeah this video made much easier , keep it up woth videos tnx.

    • @CodeMaze
      @CodeMaze  Před 2 měsíci

      I am so glad to hear that. Sorry for the late response, didn't see your reply.

  • @user-hh7cy8tr6h
    @user-hh7cy8tr6h Před 2 měsíci

    Thx for video!

    • @CodeMaze
      @CodeMaze  Před 2 měsíci

      My pleasure. Thanks for watching.

  • @andresbeltran5779
    @andresbeltran5779 Před 2 měsíci

    Excellent 😬😬

    • @CodeMaze
      @CodeMaze  Před 2 měsíci

      Thank you. Glad you like it.

  • @user-tb3js1zh1l
    @user-tb3js1zh1l Před 2 měsíci

    Hi Marinko,
    is it better to configure your type client using action delegate while registering it or in constructor like you did? You are injecting http client inside CompaniesClient, i assume that is possible to configure base url and timeout inside program.cs while registering CompaniesClient.
    Best regards

    • @CodeMaze
      @CodeMaze  Před 2 měsíci +1

      Hi. You can configure it inside the Program class, if you search through some of Microsoft's documentation, you will see they have similar examples. But, for me, it is always better to encapsulate that HttpClient configuration inside the typed client class, making the Program class cleaner with less configuration logic. Also, this is configuration strictly related to that specific client, so why not having it inside the typed client's class.

  • @10Totti
    @10Totti Před 2 měsíci

    Best Tutorial i use Tuyped Clients.

    • @CodeMaze
      @CodeMaze  Před 2 měsíci

      Thank you very much. Yeah, I also prefer typed clients.