Using HttpClient in .NET Core to Connect to APIs in C#

preview_player
Показать описание
How do you safely connect to APIs in .NET Core using C#? HttpClient is the way to go, but doing right is important. Otherwise, you could exhaust your connection pool and cause issues in your application.

0:00 - Intro
0:56 - Blazor server demo app
3:36 - Http.Json NuGet reference
4:48 - New Blazor page: Razor component
5:55 - Data models from json data
14:15 - Editing Blazor page: Page name and navigation link
16:16 - Inject and use Http client: long way
26:40 - Editing Blazor page: Blazor page render logic
31:19 - Running Demo App
33:22 - Inject and use Http client with try - catch
43:02 - Summary and concluding remarks

Thanks to Ralfs HBK for the chapter breakdown
Рекомендации по теме
Комментарии
Автор

That Paste Special magic blew my mind!

magnus
Автор

This is still relevant in 2022. When I get stuck, I search for one of your videos on the topic. I like your approach.

deltaphilip
Автор

This is my favorite kind of tutorial video. Focused, not too long, sample code. Thank you.

zoltan.halasz
Автор

15:50 "I don't think there's a weather icon"
oi-rain is perfect for it!

jugghayd
Автор

Tim. You're a Godsend. I recently spent a couple of hours writing classes for deserializing large json files. My heart sand when you pulled down the menu to convert json to classes. ! Now I have to write code to deal with multiple different devices with httpclient. I am not using DI, primarily because I don't fully understand it or how it applies to a C# WPF prog like I am developing. This was very helpful. I always love it when something I don't expect pops up in your vids. Thanks again.

wayahedia
Автор

This is awesome tim. Just one example and you connected us to hundreds of API free for consumption such as spotify or twitter APIs.

Funkfreed
Автор

Would be good to see how authorization would be applied to the API Client() as well e.g. Auth0

matthewlevis
Автор

Thank you for great step by step lesson on HttpClient. I have used couple of time, but the one-liner trick is so great!

jackieu
Автор

Thanks so much Tim, you have a way of explaining things that make it easy to understand and gives context. Much appreciated!

bavman
Автор

Cool, finally some up-to-date Http client information. Thanks Corey.

mrcalico
Автор

Thanks! I want to create a project for hands-on, but was banging my head on stackoverflow and ms documentations, got this great resource, you are doing a great job.👍

varunaggarwal
Автор

BTW, this is a truly valuable lesson. I really learned a lot about the theory as well as the nuts and bolts of getting it working. Thanks.

HeathInHeath
Автор

Thank you tim for the great content, past as json is really great 👍🏻

saadaldulaijan
Автор

Thanks a lot! It was great how you went to complex way to simplest way for us to comprehend the whole concepts. I loved it!

jonathanvargas
Автор

Loving the config file usage, good to know. Also, the one liner for a connection string is fantastic. Thanks again Tim

daniellister
Автор

Paste Special...and my mind was completely blown.

elisunday
Автор

Another great video! Even as a relatively experienced dev, there's always something I'm learning from you. Very helpful.

williamsworkshop
Автор

Im really wishing my university would have been teaching this stuff 4 years ago. MS VS is so nice.

wmd
Автор

Nice info. I think the next step would be to refactor the httpclient code out of the razor page into a weatherService class that does all that work, and inject the weatherService into the razor page to keep your layers and responsibilities de-coupled.

pilotboba
Автор

That was awesome, I am going to try to use this in some little app tests tonight!

cenaruthedruid
join shbcf.ru