How to Fetch Data from Server in Blazor Interactive Auto Render Mode - .Net 8 (Easily and Securely)

  Рет қаралды 9,259

Abhay Prince

Abhay Prince

Күн бұрын

Пікірлер: 45
@Jorgearananeyra
@Jorgearananeyra 10 ай бұрын
Good solution, it is the first video that explains how to get the httpclient to work in .Net 8, however, it seems that it is too complicated to make it work on each page that we add. I think the developers forgot that this is important for a real application. Well, all we have to do is wait for .Net 9 to come out while I return to .Net 7
@JaimeWyant
@JaimeWyant 2 ай бұрын
Great video. I agree with the guy that recommended solely using the API call. This gives you one interface and implementation that you can have in a shared project. This was a good explanation of InteractiveAuto - thanks!
@abhayprince
@abhayprince 2 ай бұрын
@@JaimeWyant but then there is that problem - Fetching data from the same app server via http call to the same app server. That does not make sense
@JaimeWyant
@JaimeWyant 2 ай бұрын
@@abhayprince It makes sense if you're thinking "I only want to do this one way". Which is generally how I like to do things. I understand your preference for using the service when running in server-mode. I would have just extracted it myself to an httpclient. I always create a separate API for my blazor apps, and never thought to just create the API directly in the app itself. That's a nice idea!
@craigmusicdude
@craigmusicdude 11 ай бұрын
This solved a problem I spent hours trying to understand. Thanks!
@waleedbensumaidea3947
@waleedbensumaidea3947 7 ай бұрын
Thank you so much Mr.Abhay for this great video. You did nice explaining about Blazor Auto render mode and the scenarios that we got when choosing this approach. We would be very grateful for you if you also do video abuse Blazor NET8 authentication and Authorization using JWT with AutoRender Mode Because this approach has some difficulties like RevalidatintServerAuthinecationStateProvider and so on...
@josepheffanga2069
@josepheffanga2069 6 ай бұрын
How about moving the interface of the services and its implementations into a library and reference them on both server and client?
@abhayprince
@abhayprince 6 ай бұрын
The problem would be implemented class. When it will run for WebAssembly it will try to directly call the database which does not exist on the client side. So it’s not going to work
@tomnewport9011
@tomnewport9011 6 ай бұрын
I am following this though with a new app build. I have created 3 libs, services.server, services.client and services.interfaces. services.interfaces is shared and the other 2 go to the respective client or server. This is working for .GetAsync() but I am now trying to refactor to use .PostAsync(jsonObj)
@halheinrich8238
@halheinrich8238 11 ай бұрын
Thank you for the video! Very helpful and much appreciated.
@yurilukashenko3175
@yurilukashenko3175 4 ай бұрын
Thank you so much for this video, it really helped me to understand how Interactive Mode works! This DI for two implementations on server and client is a really wild thing (in a good sense), I appreciate your idea. By the way, I created a regular controller instead of a minimal API. But it is also a good approach.
@AnnaThomas-d2f
@AnnaThomas-d2f 3 ай бұрын
Regular controller is not working for me. I included the builder.Services.AddControllers() . But nothing working. Can you give an example.
@manojnaik5643
@manojnaik5643 9 ай бұрын
Nice video presentation and architecture of blazer components, I have implemented the business logic to post and get data from third-party API in the services project class library and referenced the same in the server project and API endpoints using a minimal API approach, how I can use HTTP client to access server minimal API endpoints in this case by creating proxy in my client(web assembly) project?
@headcode
@headcode 3 ай бұрын
Great video! A couple of questions: 1. When I try this and follow the steps in your video, it works fine, except when I browse to another page (click another link) and come back to "fetch-data." I get a 404 on the api request. The only step difference is I created an ApiController rather than using minimal api. 2. Why are there multiple calls to the service when the component loads?
@abhayprince
@abhayprince 3 ай бұрын
Using minimal api or controller should not change anything. Something else might be causing this behaviour Do you have some repo, I can review? For question 2 - it happens because of pre-rendering
@MB-nw5sz
@MB-nw5sz 10 ай бұрын
Nice video thank you. Another approach might be to simply use the the api call in both the server AND the client code, making the code work the same in both.
@abhayprince
@abhayprince 10 ай бұрын
Then there will be an extra call from server. From the server side component we will make api call to the same server which does not make sense
@MB-nw5sz
@MB-nw5sz 10 ай бұрын
@@abhayprince Ahh yes, but since it's auto render mode, it's only for the first call - just a suggestion to simplify the code. It would not make sense otherwise. Still nice to see another way of working, using the alternative interface implementation :)
@nileshgr
@nileshgr 11 ай бұрын
Very helpful in understanding how to use InteractiveAuto. Thanks!
@hVSjRJ53
@hVSjRJ53 2 ай бұрын
Thank you 👍👍
@pavelshkomov8777
@pavelshkomov8777 5 ай бұрын
Thank you for this video! I see one small problem with this approach: the minimal api (/api/fetch-data) is accessible to everyone from the outside. How can I make it inaccessible to everyone except FetchDataBlazorAuto.Client?
@abhayprince
@abhayprince 5 ай бұрын
It depends on the requirement. We can implement Auth easily, and then add .RequireAuthorization() etc methods on minimal api endpoints
@Don-ii4vm
@Don-ii4vm 5 ай бұрын
Excellent video. Thanks.
@amusefly
@amusefly 11 ай бұрын
thank you very much,you saved many times for me.
@xdiegors
@xdiegors 10 ай бұрын
Thank you! Nice video!
@olagisrarikis
@olagisrarikis 11 ай бұрын
Excellent thank you! Saved me a lot of time.
@shabanelmogy7912
@shabanelmogy7912 Жыл бұрын
how can i sync between sqlite on mobile offline and remote database (restapi with sql server ) ?
@waleedbensumaidea3947
@waleedbensumaidea3947 7 ай бұрын
Did you find any solution for your question
@shabanelmogy7912
@shabanelmogy7912 Жыл бұрын
i nees example for blazor hybrid with mobile devices like camera/sound/contacts/send message/maps
@shabanelmogy7912
@shabanelmogy7912 Жыл бұрын
in blazor hybrid how can prevent button hover to show as native?
@MihaiMoisei
@MihaiMoisei 10 ай бұрын
Thank you very much.
@CheerfulMountainVolcano-Jay
@CheerfulMountainVolcano-Jay 11 ай бұрын
Demo on Client service using rapid would be appreciated.
@abhayprince
@abhayprince 11 ай бұрын
you mean Refit Client?
@davemasters
@davemasters 8 ай бұрын
Helpful!
@manojnaik5643
@manojnaik5643 6 ай бұрын
can you please guide on how to make user login session in this architecture.
@abhayprince
@abhayprince 6 ай бұрын
Using cookie Auth. You can try creating a new project with Authentication Individual account, and then review the generated code
@shabanelmogy7912
@shabanelmogy7912 Жыл бұрын
I want Full Example For NaigationManager (kill component when close / prevent navigation on specific event)
@Crisis742
@Crisis742 Жыл бұрын
Thank you!
@okcharles7
@okcharles7 11 ай бұрын
I can't find any benefit of choosing interactive auto mode. Your way of fetching is just the same as you can under 3 tier model of web api + front end (blazor wasm).
@abhayprince
@abhayprince 11 ай бұрын
If you dont want you user to wait till the app downloads Mbs of webassembly to the browser, Its great to start with InteractiveAuto
@tonymarks4694
@tonymarks4694 Ай бұрын
IF this is the only or best way of doing things then its utterly ridiculous on MS part ( not your fault). This should require nothing more than hitting an api and pulling in the data as is done with every JS framework with the framework itself taking care of the indentification and switching . Lets not forget that this whole issue of switching from signalR to webassembly is because webassembly takes too long to transfer to the client. so all this tedious work is just to compensate for a technology that cant run as smoothly as JS. Since for other things you have to already resort to Jsinterop you have to ask yourslef how much do I really hate Js to have to do all this? Using something faster and just as easy to learn like svelte is MILES better than this.
@abhayprince
@abhayprince Ай бұрын
I agree with this. Right now this is the only way. There is a library which makes it easier to write, cannot remember its name right now. They do all this for you
@nicolasgonzalezl
@nicolasgonzalezl 7 ай бұрын
Great video. Thanks!
@shabanelmogy7912
@shabanelmogy7912 Жыл бұрын
in blazor hybrid how can prevent button hover to show as native?
@abhayprince
@abhayprince Жыл бұрын
using css styles. You need to play around with css
Blazor Render Modes in .NET 8 and which Web App Template to choose
28:51
Christopher Bell
Рет қаралды 2,4 М.
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН
I was just passing by
00:10
Artem Ivashin
Рет қаралды 18 МЛН
Одну кружечку 😂❤️
00:12
Денис Кукояка
Рет қаралды 1,4 МЛН
Fetching Data Doesn't Get Better Than This
6:58
Josh tried coding
Рет қаралды 136 М.
[SEI' 24] Modern Systems Programming: Rust and Zig - Aleksey Kladov
55:18
CeSIUM - Centro de Estudantes de Engenharia Informática da Universidade do Minho
Рет қаралды 4,2 М.
Beautiful Sortable Drag & Drop Lists for your Blazor Apps
32:11
8 Free and Open Source Blazor UI Libraries
9:42
Claudio Bernasconi
Рет қаралды 43 М.
CRUD with the Blazor WebAssembly Render Mode in .NET 8 🔥
50:49
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН