I needed this so much, you saved me from a deadline. Thank you So Much
@jayantlalguru67804 жыл бұрын
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"); } }
@ernanmaisels4 жыл бұрын
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.
@Nynxxx4 жыл бұрын
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.
@SupunNimantha3 жыл бұрын
same issue . have you resolved this ?
@ernanmaisels3 жыл бұрын
@@SupunNimantha Yes. just use the program.cs file and insert all your services on Main method. Good luck!
@SupunNimantha3 жыл бұрын
@@ernanmaisels yeah that worked. I had some services
@EduardoSantos-tr4gb2 жыл бұрын
And what about the localhost url u do something?
@cristians29764 жыл бұрын
You are doing an excellent job
@BCLBlazorCollectionsLibrary4 жыл бұрын
Exactly, I love his every blazor tutorial :)
@alihaydar30214 жыл бұрын
I really like your work arrangements .. just wondering why you didn't use generic repository and unit of work .. it's more usable
@LetCode966664 жыл бұрын
Love this playlist!
@yyttommy2456 Жыл бұрын
Great, I do it. Thank you very much, please keeping up
@eeveeadm83674 жыл бұрын
Thank You Sir. God Bless You.
@CCPony4 жыл бұрын
I love the Venkat!
@AniketRamekar4 жыл бұрын
Very good tutorial Venkat. Thank you.
@kameshp684 жыл бұрын
Nice presentation
@MegaxAT2 жыл бұрын
a great video! thanks
@aikidoshi0074 жыл бұрын
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?
@AniketRamekar4 жыл бұрын
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
@aikidoshi0074 жыл бұрын
@@AniketRamekar Thanks Aniket, sorry for the late response, I've been so busy, now getting back to Blazor.
@Rajeshsingh-ws5th4 жыл бұрын
Great Venkat.
@sathishkomakul4 жыл бұрын
Plz start tutorial of C# WPF
@zorigdavaag.83544 жыл бұрын
Thank you so much. I have a question. what is the alternatives for Microsoft.AspNetCore.Components namespace since this is in preview
@kalapalababurao17883 жыл бұрын
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 Жыл бұрын
I am getting the same problem. Did you find any alternate solution for this?
@nichodemusomedo44 жыл бұрын
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.
@jamaissans23774 жыл бұрын
Thank you Mr.
@moawadabdelbasset98964 жыл бұрын
thanks for you how can i call the REST API in xamarin forms
@AniketRamekar4 жыл бұрын
use HttpClient, refer: docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/web-services/rest
@rainron26643 жыл бұрын
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.😊😊
@HRJosef2 жыл бұрын
Is somewhere avaiable source code? I missed something and i would like to compare?
@sabrinadiaf32304 жыл бұрын
please sir what do you think about using Refit and create an SDK to consume the API?
@EngDuraid4 жыл бұрын
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.
@Beji-boy3 жыл бұрын
I get it "An unhandled exception occurred while processing the request. JsonReaderException: '
@mozaherhossain10364 жыл бұрын
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. Жыл бұрын
Reinstall windows .
@stefanvettiger63084 жыл бұрын
The method "OnInitializedAsync" in the class "EmployeeListBase" of the Web project is called automatically twice when i run the project! Why?
@ArpitSharma-g1b9 ай бұрын
search on stackoverflow
@EnriqueElcamel2 жыл бұрын
Hello, I'm having this weird error "System.Text.Json.JsonException: '
@pylvr80214 жыл бұрын
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
@ronswanson96354 жыл бұрын
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
@ManuelHernandez-vi1it4 жыл бұрын
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)
@amer-ik7jj4 жыл бұрын
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-ik7jj4 жыл бұрын
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. Жыл бұрын
Reinstall windows .
@gulshan8033 жыл бұрын
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. Жыл бұрын
Reinstall windows .
@mytrolls5866 Жыл бұрын
why again server? already if we have web app very confusing please clear
@rohhappyness72974 жыл бұрын
I canot call api in employee service to consume any one can help?
@siddharthsharma27913 жыл бұрын
Sir can you Suggest me how can i use web Api in Razor pages in this way
@vinitmishra93374 жыл бұрын
Sir can i get any help in vb.net chats formation with chart.js and sql
@Rajeshsingh-ws5th4 жыл бұрын
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?
@vladnik81154 жыл бұрын
What do they offer to use instead of EF ? (write EF by yourself! :) )
@chezchezchezchez4 жыл бұрын
vlad nik dapper and SimpleCRUD. Your welcome! 👊🏻
@vladnik81154 жыл бұрын
@@chezchezchezchez How will you work with multiple related tables with a dapper? Can you give a link to examples?
@renusai23 Жыл бұрын
hi, i am getting data not retrieved server error 500
@njokuiyke014 жыл бұрын
please who can help with this error: JsonException: '
@stefanvettiger63084 жыл бұрын
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 '
@ranja67934 жыл бұрын
I have the same error. Did you solved it?
@ranja67934 жыл бұрын
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 });
@tamasballai87033 жыл бұрын
@@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.
@EnriqueElcamel2 жыл бұрын
@@tamasballai8703 can you please elaborate this i dont understand. Thank you
@Rajeshsingh-ws5th4 жыл бұрын
take care of your health due to covid-19
@maxsoftwaregraphics57144 жыл бұрын
Dear sir null value is showing
@maxsoftwaregraphics57144 жыл бұрын
Please helps me
@hughcoleman94004 жыл бұрын
@@maxsoftwaregraphics5714 Do you have same issue as discussed by Vivek a month ago, if so I don't understand solution either.
@hughcoleman94004 жыл бұрын
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
@rajushahi50894 жыл бұрын
Authentication Exception: The remote certificate is invalid according to the validation procedure.
@ajanyhc4 жыл бұрын
issue the following command: dotnet dev-certs https --trust
@stancyvincent75502 жыл бұрын
Where to use that command
@mainframehardtutorials84414 жыл бұрын
Can we directly call database information into the Blazor App without any Api
@Nynxxx4 жыл бұрын
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.
@aussieraver71822 жыл бұрын
6:59
@wassollderscheiss333 жыл бұрын
I run into CORS problems. Meh
@wassollderscheiss333 жыл бұрын
Had to do services.AddCors() in ConfigureServices(...) of WebApi project and app.UseCors(a => a.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().SetIsOriginAllowed(b => true)) in Configure(...)