Тёмный

Call REST API from ASP NET Core Blazor 

kudvenkat
Подписаться 831 тыс.
Просмотров 68 тыс.
50% 1

How to call and consume a REST API from ASP.NET Core Blazor application.
Text Article and Slides
www.pragimtech.com/blog/blazo...
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
/ @aarvikitchen5572
Blazor tutorial for beginners
• Blazor tutorial for be...
Blazor Blog
www.pragimtech.com/courses/bl...
Angular, JavaScript, jQuery, Dot Net & SQL Playlists
ru-vid.com...
Let's gift education together
/ kudvenkat

Наука

Опубликовано:

 

12 апр 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 111   
@Alex-bc3tt
@Alex-bc3tt 3 года назад
I needed this so much, you saved me from a deadline. Thank you So Much
@LetCode96666
@LetCode96666 4 года назад
Love this playlist!
@eeveeadm8367
@eeveeadm8367 4 года назад
Thank You Sir. God Bless You.
@AniketRamekar
@AniketRamekar 4 года назад
Very good tutorial Venkat. Thank you.
@Rajeshsingh-ws5th
@Rajeshsingh-ws5th 4 года назад
Great Venkat.
@CCPony
@CCPony 3 года назад
I love the Venkat!
@jamaissans2377
@jamaissans2377 4 года назад
Thank you Mr.
@first8208
@first8208 2 года назад
a great video! thanks
@yyttommy2456
@yyttommy2456 7 месяцев назад
Great, I do it. Thank you very much, please keeping up
@jayantlalguru6780
@jayantlalguru6780 4 года назад
Here is a small piece of code to call the API. This is generic so that we don't need to write the code again and again. //THE INTERFACE public interface IApiHandler { Task GetAsync(string url); } //THE IMPLEMENTATION TO CALL THE API public class ApiHandler : IApiHandler { private readonly HttpClient _httpClient; public ApiHandler(HttpClient httpClient) { _httpClient = httpClient; } public async Task GetAsync(string url) { return await _httpClient.GetJsonAsync(url); } //TODO //CODE FOR POST, PUT, DELETE CAN BE ADDED } //THE STARTUP CLASS services.AddHttpClient(client => { client.BaseAddress = new Uri("localhost:44336/"); //ADD YOUR BASE URL INSIDE THE BRACKET }); //CALLING THE SERVICE(ApiHandler) public class EmployeeListBase : ComponentBase { [Inject] private IApiHandler _apiHandler { get; set; } public IEnumerable Employees { get; set; } protected override async Task OnInitializedAsync() { Employees = await _apiHandler.GetAsync("api/Employees/GetEmployees"); } }
@kameshp68
@kameshp68 3 года назад
Nice presentation
@cristians2976
@cristians2976 4 года назад
You are doing an excellent job
@BCLBlazorCollectionsLibrary
@BCLBlazorCollectionsLibrary 4 года назад
Exactly, I love his every blazor tutorial :)
@alihaydar3021
@alihaydar3021 4 года назад
I really like your work arrangements .. just wondering why you didn't use generic repository and unit of work .. it's more usable
@zorigdavaag.8354
@zorigdavaag.8354 4 года назад
Thank you so much. I have a question. what is the alternatives for Microsoft.AspNetCore.Components namespace since this is in preview
@nichodemusomedo4
@nichodemusomedo4 4 года назад
Thank you. I would like to let you know that while testing on creating a new employee, I happened to find a false error of email address already exists for a new client and new email address, I ran the application in debug mode and postman for this very lesson. It would be nice to give an explanation as to why that happened as I was expecting to commit the new employee without any problem.
@sabrinadiaf3230
@sabrinadiaf3230 4 года назад
please sir what do you think about using Refit and create an SDK to consume the API?
@rainron2664
@rainron2664 3 года назад
Sir may i ask, why you are using Httpclientfactory instead of signalr to connect to the API? Like what the browser does to connect to blazor server? thank you in advance.😊😊
@EngDuraid
@EngDuraid 4 года назад
Thank you but i tried to use a generic service instead (ApiService) which implement (IApiService) then i tried to register it the same way you did but that didn't work can you please tell me a hint how to achieve this please.
@aikidoshi007
@aikidoshi007 4 года назад
Thanks Venkat, great job. I've been doing my head in trying to get this very thing working and here it all is in one tidy package. When the product is deployed the hard-coded base URL will not work, how would you set that up so it can be different and automatically set in each deployment environment please?
@AniketRamekar
@AniketRamekar 4 года назад
It depends based on how secure you want things to be. You can use appsettings.{Environment}.json files (link1), or go all out with app secrets (link2) link1:docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1 link2:docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-3.1&tabs=windows
@aikidoshi007
@aikidoshi007 4 года назад
@@AniketRamekar Thanks Aniket, sorry for the late response, I've been so busy, now getting back to Blazor.
@ernanmaisels
@ernanmaisels 3 года назад
Thanks a lot for all your great tutorials. about this video - in 3:20 you are talking about Startup.cs file. but in web assembly project, there is just Program.cs file.
@Nynxxx
@Nynxxx 3 года назад
I am not sure if you needed anything clarified, but he did mention that this video series is just going to cover Blazor Server and not Blazor WASM.
@SupunNimantha
@SupunNimantha 3 года назад
same issue . have you resolved this ?
@ernanmaisels
@ernanmaisels 3 года назад
@@SupunNimantha Yes. just use the program.cs file and insert all your services on Main method. Good luck!
@SupunNimantha
@SupunNimantha 3 года назад
@@ernanmaisels yeah that worked. I had some services
@EduardoSantos-tr4gb
@EduardoSantos-tr4gb 2 года назад
And what about the localhost url u do something?
@sathishkomakul
@sathishkomakul 4 года назад
Plz start tutorial of C# WPF
@kalapalababurao1788
@kalapalababurao1788 3 года назад
Microsoft.AspNetCore.Blazor.HttpClient NuGet package is not available to download, however I searched in google and downloaded that package of version 3.2.0-preview3.20168.3 depricated. it is working to extract data from database using EFC and using API , but it is not working for Blazor app EmployeeListDetails :Shall you please provide that NuGet package.
@keshavprasad
@keshavprasad Год назад
I am getting the same problem. Did you find any alternate solution for this?
@Beji-boy
@Beji-boy 3 года назад
I get it "An unhandled exception occurred while processing the request. JsonReaderException: '
@ronswanson9635
@ronswanson9635 4 года назад
I did a blunder while posting in postman, I posted it in different format and not in JSON. I cannot load the details on that page, but I am able to retrieve employees/1 or employees/2 except for the one that I wrongly posted. I do not know how to delete it as I tried to delete it, it showed some error. Anyone help me with this
@pylvr8021
@pylvr8021 4 года назад
can someone please explain to me why he uses services to call rest api when he already have a class library , when should we use class library or services
@HRJosef
@HRJosef 2 года назад
Is somewhere avaiable source code? I missed something and i would like to compare?
@ManuelHernandez-vi1it
@ManuelHernandez-vi1it 3 года назад
I am getting this issue : SocketException: An existing connection was forcibly closed by the remote host. Unknown location IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) HttpRequestException: The SSL connection could not be established, see inner exception. System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
@moawadabdelbasset9896
@moawadabdelbasset9896 4 года назад
thanks for you how can i call the REST API in xamarin forms
@AniketRamekar
@AniketRamekar 4 года назад
use HttpClient, refer: docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/web-services/rest
@vinitmishra9337
@vinitmishra9337 4 года назад
Sir can i get any help in vb.net chats formation with chart.js and sql
@stefanvettiger6308
@stefanvettiger6308 3 года назад
The method "OnInitializedAsync" in the class "EmployeeListBase" of the Web project is called automatically twice when i run the project! Why?
@user-rk5rv9jq3i
@user-rk5rv9jq3i 4 месяца назад
search on stackoverflow
@rohhappyness7297
@rohhappyness7297 3 года назад
I canot call api in employee service to consume any one can help?
@EnriqueElcamel
@EnriqueElcamel 2 года назад
Hello, I'm having this weird error "System.Text.Json.JsonException: '
@Rajeshsingh-ws5th
@Rajeshsingh-ws5th 4 года назад
take care of your health due to covid-19
@siddharthsharma2791
@siddharthsharma2791 3 года назад
Sir can you Suggest me how can i use web Api in Razor pages in this way
@mozaherhossain1036
@mozaherhossain1036 4 года назад
I got an Error while call rest api in blazor. The error is -> "AuthenticationException: The remote certificate is invalid according to the validation procedure. System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception) HttpRequestException: The SSL connection could not be established, see inner exception. System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)". What should I do, please suggest me. Thank you...
@Desperate4Freedom.
@Desperate4Freedom. 7 месяцев назад
Reinstall windows .
@gulshan803
@gulshan803 3 года назад
Hi, i am facing this "The remote certificate is invalid according to the validation procedure. " issue while consuming rest API on "return await httpclient.getjsonasync(Employee[])("api/employee")". plz help me for the same...
@Desperate4Freedom.
@Desperate4Freedom. 7 месяцев назад
Reinstall windows .
@renusai23
@renusai23 10 месяцев назад
hi, i am getting data not retrieved server error 500
@mytrolls5866
@mytrolls5866 9 месяцев назад
why again server? already if we have web app very confusing please clear
@amer-ik7jj
@amer-ik7jj 4 года назад
An unhandled exception occurred while processing the request. AuthenticationException: The remote certificate is invalid according to the validation procedure. System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception) HttpRequestException: The SSL connection could not be established, see inner exception. System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
@amer-ik7jj
@amer-ik7jj 4 года назад
services.AddHttpClient(client => { client.BaseAddress = new Uri("localhost:44330/"); }) .ConfigurePrimaryHttpMessageHandler(sp => new HttpClientHandler { AllowAutoRedirect = false, ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true, SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 }); this solve problem
@Desperate4Freedom.
@Desperate4Freedom. 7 месяцев назад
Reinstall windows .
@Rajeshsingh-ws5th
@Rajeshsingh-ws5th 4 года назад
Most of the time, my seniors (some of them worked with Microsoft as well) suggested me not to use EF in our project. If this is true, why so?
@vladnik8115
@vladnik8115 4 года назад
What do they offer to use instead of EF ? (write EF by yourself! :) )
@chezchezchezchez
@chezchezchezchez 4 года назад
vlad nik dapper and SimpleCRUD. Your welcome! 👊🏻
@vladnik8115
@vladnik8115 4 года назад
@@chezchezchezchez How will you work with multiple related tables with a dapper? Can you give a link to examples?
@njokuiyke01
@njokuiyke01 4 года назад
please who can help with this error: JsonException: '
@stefanvettiger6308
@stefanvettiger6308 3 года назад
This is because you get an error response instead of the real answer. An error response is in XML format an always starts with a '
@ranja6793
@ranja6793 3 года назад
I have the same error. Did you solved it?
@ranja6793
@ranja6793 3 года назад
I found out the problem: services.AddHttpClient(client => { // BaseAddress where the uri is available ! client.BaseAddress = new Uri("localhost:44338/"); // Api baseadress. this is the corrent uri //client.BaseAddress = new Uri("localhost:44385/"); // server baseadress. this leads to the error });
@tamasballai8703
@tamasballai8703 3 года назад
@@ranja6793 I've met with the same issue. Instead of the Api's port number I've given the Web's port number. Thank you so much for this comment, my problem has been solved.
@EnriqueElcamel
@EnriqueElcamel 2 года назад
@@tamasballai8703 can you please elaborate this i dont understand. Thank you
@mainframehardtutorials8441
@mainframehardtutorials8441 3 года назад
Can we directly call database information into the Blazor App without any Api
@Nynxxx
@Nynxxx 3 года назад
You can, but it makes your app not scalable assuming that at some point you may want to switch to Blazor WASM. EDIT: Also, creating an API to call from can make it easier to implement new apps that aren't able to talk directly to the database, such as a mobile app that also wants to use the database, I am using xamarin to make an app, and we must have an API since it is not able to directly access the database.
@rajushahi5089
@rajushahi5089 4 года назад
Authentication Exception: The remote certificate is invalid according to the validation procedure.
@ajanyhc
@ajanyhc 3 года назад
issue the following command: dotnet dev-certs https --trust
@stancyvincent7550
@stancyvincent7550 2 года назад
Where to use that command
@maxsoftwaregraphics5714
@maxsoftwaregraphics5714 4 года назад
Dear sir null value is showing
@maxsoftwaregraphics5714
@maxsoftwaregraphics5714 4 года назад
Please helps me
@hughcoleman9400
@hughcoleman9400 4 года назад
@@maxsoftwaregraphics5714 Do you have same issue as discussed by Vivek a month ago, if so I don't understand solution either.
@hughcoleman9400
@hughcoleman9400 4 года назад
In my case it was because in my live version I had not included the code explained in part 8, Loading indicator explained reason for error
@aussieraver7182
@aussieraver7182 2 года назад
6:59
@wassollderscheiss33
@wassollderscheiss33 3 года назад
I run into CORS problems. Meh
@wassollderscheiss33
@wassollderscheiss33 3 года назад
Had to do services.AddCors() in ConfigureServices(...) of WebApi project and app.UseCors(a => a.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().SetIsOriginAllowed(b => true)) in Configure(...)
@pankajcodesdot490
@pankajcodesdot490 2 года назад
Install-Package Microsoft.AspNetCore.Blazor.HttpClient -Version 3.2.0-preview3.20168.3 :- command
@k.divyaswarnkar5975
@k.divyaswarnkar5975 Год назад
it is not available in nuget package manager can you please suggest how could i download ?
Далее
Blazor route parameters
10:21
Просмотров 36 тыс.
Brutally honest advice for new .NET Web Developers
7:19
ASP NET Core REST API DbContext
10:35
Просмотров 64 тыс.
Post in ASP NET Core REST API
11:29
Просмотров 46 тыс.
Blazor: Why 2024 Is The Year Of Blazor 🚀
9:40
Просмотров 24 тыс.
Compare validation in blazor
8:55
Просмотров 16 тыс.
Blazor EventCallback
7:48
Просмотров 34 тыс.
Blazor Tutorial : Call REST API | CRUD Methods - EP10
20:54
Blazor component parameters
6:56
Просмотров 31 тыс.
Blazor data binding
8:15
Просмотров 33 тыс.
ЗАБЫТЫЙ IPHONE 😳
0:31
Просмотров 20 тыс.