Consume REST API from Blazor WebAssembly

  Рет қаралды 19,770

Roozbeh Shad

Roozbeh Shad

Күн бұрын

In this tutorial, I'll show you how to call and consume a REST API service from a Blazor WebAssembly application.
I'll explain how to enable CORS (Cross-Origin Resource Sharing) on the RESTful service side.
You'll learn how to register HttpClient with the address of WebAPI service and inject it to the Razor components.
Finally, I'll show you how to display binary images of categories in the Northwind database.

Пікірлер: 35
@Valoo24
@Valoo24 Жыл бұрын
Thank you so much for such a concise yet complete explanation. I couldn't find out why I couldn't consume my API. Turns out I completly forgot about CORS. Keep up the good work !
@MrNoga1984
@MrNoga1984 2 жыл бұрын
Good job bro. Very simple yet instructive. Just what I needed to get me off my journey in Blazor WASM
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks MrNoga1984. I’m happy you found it useful.
@laurosantana1477
@laurosantana1477 2 жыл бұрын
God bless you man!!! I was having a bad time with this blazor error in the bottom, you save all my work
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks. I'm glad it was helpful. Have you seen the latest video?
@theentein
@theentein 2 жыл бұрын
You are my hero man for today :D
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks The Entein! I'm happy you liked it.
@Pasi70150
@Pasi70150 5 ай бұрын
Good video 👍👍👍
@mesquitaasas
@mesquitaasas Жыл бұрын
Many thanks for sharing!
@RoozbehShad
@RoozbehShad Жыл бұрын
My pleasure!
@JC-yv1qj
@JC-yv1qj 2 жыл бұрын
Very useful, sepaas gozaaram
@RoozbehShad
@RoozbehShad 2 жыл бұрын
خواهش می‌کنم. I'm glad you like it. If you're interested in this series, please subscribe to get notified of the upcoming videos.
@JC-yv1qj
@JC-yv1qj 2 жыл бұрын
@@RoozbehShad Indeed, be salamat
@موسیامیری-س7غ
@موسیامیری-س7غ 2 жыл бұрын
سلام اقای شاد . تدریستون عالی هست ، و از ویدیوتون ممنونم . میخواستم درخواست کنم یک ویدو بسازید در باره نحوه تعیین سطح دسترسی کاربران با نقش های مختلف به سطوح مختلخ . authentication . این مسئله رو زیاد دنبالش میگردم ولی چیزی که اصولی باشه رو پیدا نمیکنم . از ویدو خوبتون هم متشکرم . ❤❤❤❤❤
@RoozbehShad
@RoozbehShad 2 жыл бұрын
از توجه مثبت شما سپاسگزارم. اتفاقن چیزی که راجع به سطوح مختلف دسترسی اشاره کردید یکی از برنامه های آموزشی مورد نظر من هست که تهیه و ازائه کنم، ولی چون این مجموعه بر طبق یک روال منطقی و از پیش تعیین شده تدوین شده، ارائه این ویدیو در زمان حاظر در دستور کارم نیست. با این وجود مطمئنم که ویدیوهای بعدی را بسیار آموزنده، جذاب و مفید خواهید یافت.
@موسیامیری-س7غ
@موسیامیری-س7غ 2 жыл бұрын
@@RoozbehShad متشکرم ، منتظر ویدیو های بعدیتون هستم
@josecarlosmacoratti
@josecarlosmacoratti 3 жыл бұрын
Good job
@RoozbehShad
@RoozbehShad 3 жыл бұрын
Thanks Jose.
@MiekeJansenvanRensburg
@MiekeJansenvanRensburg 2 жыл бұрын
Thank you so much!
@RoozbehShad
@RoozbehShad 2 жыл бұрын
You're welcome! Have you seen the latest video?
@eduarsanchez1851
@eduarsanchez1851 2 жыл бұрын
Good contens
@RoozbehShad
@RoozbehShad 2 жыл бұрын
I'm glad you liked it. I released a new video on the first day of the new year. Please watch and enjoy it!
@krzysztofbarbarski3966
@krzysztofbarbarski3966 2 жыл бұрын
Get request works, but i have this samme error for Post request...
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks for reaching out. Try the following in your ConfigureServices method of the Startup class in the api project: services.AddCors(options => { options.AddPolicy(name: "AllowBlazorOrigin", builder => { builder.WithOrigins("localhost:53555", "localhost:44380", "localhost:5000", "localhost:5001") //.AllowAnyHeader() //.AllowAnyMethod() .WithHeaders("Content-Type"); }); }); Change the addresses based on yours and let me know if you need more help. Regards, Roozbeh
@qutiephoebe2154
@qutiephoebe2154 2 жыл бұрын
Great vid.👍😁 I'm a bit new to blazor web assembly. In the 4:50 of the vid, Can a web assembly consume multiple Web Api base addresses? Let's say the app is consuming 1 web api from amazon and another web api from Microsoft. Is that possible? Thanks.
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks @qutiephoebe2154 and sorry for such late reply. Yes, you can. You just need to register each one with the DI container as we did in the video and use each one whenever needed. If you need more help let me know. Regards, Roozbeh
@torrvic1156
@torrvic1156 Жыл бұрын
What about DELETE, PUT and POST operations sir? Thanks for the video anyway!
@amirpanah4197
@amirpanah4197 Жыл бұрын
کد این آموزش رو نیاز دارم، اگه امکانش هست برام بفرست
@RoozbehShad
@RoozbehShad Жыл бұрын
سلام امیر جان، ببخشید بخاطر تاخیر طولانی در ارسال این پاسخ. خیلی شلوغ بودم. شما می تونی کد هر ویدیو رو بطور جداگانه از گوگل درایو من به آدرس زیر دانلود کنی: drive.google.com/drive/folders/1-7yxcskfrwHi6aPXaujAnVdR2kHd8yXq هر سوال دیگری که داشته باشی من در خدمتم.
@julianpercivalortizherrera5979
@julianpercivalortizherrera5979 2 жыл бұрын
Muy util
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks Julian for your positive comment. If you're interested in the upcoming videos and you haven't subscribed yet, please do it to get notified of the new ones. Thanks, Roozbeh Shad
@amirpanah4197
@amirpanah4197 Жыл бұрын
سلام روزبه جان
@probalroy76
@probalroy76 Жыл бұрын
Background music is annoying.
@MegaxAT
@MegaxAT 2 жыл бұрын
great video! could you upload the source code to github please?
@RoozbehShad
@RoozbehShad 2 жыл бұрын
Thanks Jay for your support. I have plan to do it soon, but in the meantime you can get the source code on my google drive here: drive.google.com/drive/folders/1-7yxcskfrwHi6aPXaujAnVdR2kHd8yXq
HttpClient in Blazor Webassembly
14:42
kudvenkat
Рет қаралды 27 М.
Blazor WebAssembly ASP.NET Core Hosted in .NET 8 🔥
15:37
Patrick God
Рет қаралды 24 М.
Air Sigma Girl #sigma
0:32
Jin and Hattie
Рет қаралды 45 МЛН
Andro, ELMAN, TONI, MONA - Зари (Official Music Video)
2:50
RAAVA MUSIC
Рет қаралды 2 МЛН
번쩍번쩍 거리는 입
0:32
승비니 Seungbini
Рет қаралды 182 МЛН
How to CALL POST API in C#! - THIS EASY!
14:15
tutorialsEU - C#
Рет қаралды 83 М.
Real-Time Notifications Using Blazor and SignalR from scratch
19:43
Milan Jovanović
Рет қаралды 40 М.
Call Web Api in .Net 6 Blazor Server HttpClient Rest Api
18:56
Coding Jackpot
Рет қаралды 15 М.
8 Free and Open Source Blazor UI Libraries
9:42
Claudio Bernasconi
Рет қаралды 45 М.
Blazor Tutorial : Call REST API | CRUD Methods - EP10
20:54
CuriousDrive: Solve Coding Problems & Win Prizes!
Рет қаралды 32 М.
Air Sigma Girl #sigma
0:32
Jin and Hattie
Рет қаралды 45 МЛН