This Blazor Issue Could Ruin Your Project 🔥 Learn How to Avoid It!

  Рет қаралды 14,556

Patrick God

Patrick God

Күн бұрын

Пікірлер: 48
@markusn4614
@markusn4614 8 ай бұрын
SOLUTION: The way you solve this problem in WASM with prerendering is to have all your pages in the server project, and use WASM components as islands, where you inject the needed state as parameters. So for example in the Weather page you would have the table as a WeatherTable component, that takes the weather data as a parameter. Blazor automatically serializes and hydrates the parameters, so this removes any need for additional fetches and PersistentComponentState usage.
@DaveForster1970
@DaveForster1970 8 ай бұрын
do you have an example project you can share with this approach ?
@Wouldntyouliketoknow2
@Wouldntyouliketoknow2 8 ай бұрын
I see. So the WeatherTableComponent in that example doesnt do any fetch in OnInitialised but it would expect OnParamatersChanged (cant remember method name off the cuff) to be fired on the client side right - once the state paramater is set?
@cristovaomorgado
@cristovaomorgado 8 ай бұрын
WOW I've been having this issue and never understood the why! GREAT!!!!!
@chairmakerPete
@chairmakerPete 5 ай бұрын
Useful info. I'm staying away from Blazor web assembly for a few more versions in the hope it'll settle down.
@margosdesarian
@margosdesarian 8 ай бұрын
Great Video Patrick, these sort of things, where information falls between the cracks, it is really great to explain it
@poteb
@poteb 8 ай бұрын
Another reason I like the clean WASM+hosted model a lot more than this confusion mess.
@classiccomputing
@classiccomputing 8 ай бұрын
Great catch! I saw this problem and didn’t know what was going on!
@gordantadic5156
@gordantadic5156 8 ай бұрын
Thank you for the video that saved me a ton of nerves! It would be nice if you could explain how to run javacsript in Blazor web applications on the server side. Another black hole in the new Blazor. Things that used to run on net 7 no longer work on net 8?!?
@bulicminda2220
@bulicminda2220 8 ай бұрын
YEP- JS Nightmare !
@orterves
@orterves 2 ай бұрын
Wouldn't running JS server side imply a JS engine on the server? I guess you could hack a call to NodeJS. But it'd probably be better to separate client side only blazor code and ensure it only runs client side
@rezvlt9285
@rezvlt9285 6 күн бұрын
What if my project is uses interactive server side rendering? How can I prevent the flickering without turning of prerendering for SEO purposes?
@slopapa
@slopapa 8 ай бұрын
Great video! Another big issue with Blazor is how to best handle reconnection; how to handle when the browser tab sleeps or connection is lost. By default you get that "Could not reconnect to server. Reload page to restore functionality."
@rankarat
@rankarat 8 ай бұрын
Blazor Server != Blazor SSR.
@okcharles7
@okcharles7 7 ай бұрын
It it true that the problem was not solvable before Blazor 8. Now you have two options : one is as this video introduced: client side rendering (with help of prerendering). Another is auto render mode where it transits from web socket to web assembly so web socket session will gracefully end under a reasonably fast line speed. Once web assembly is cached, no web socket connection will be made again. If you don't like that, go to traditional MVC or Web Pages.
@k3dare
@k3dare 8 ай бұрын
I'm starting a new project of web app, I am a little bit confusing is I should just do everything rendered on the server (so without the .Client) project or just do as you did with 1 project for the server part and 1 project for the client app ? It looks like that adds a lot of complexity (as then you need to create new API endpoints instead of just rendering it on the server, probably more stuff to handle authentication properly I guess?) What would you recommend ?
@schreiber-it-consulting
@schreiber-it-consulting 8 ай бұрын
Great video. Thanks! Just one question: Why not just use PersistentComponentState?
@Krasipeace
@Krasipeace 8 ай бұрын
omg... finally figured out the freaking bug! Thank you so much!
@kurdishfreeman7568
@kurdishfreeman7568 8 ай бұрын
Only when you are excited for something, they come with all these confusing hidden settings and switches here and there. It is already difficult to debug, and then you have to handle this too on top of it. Just use razor pages and help your brain relax.
@rmbl349
@rmbl349 4 ай бұрын
does it open a websocket only for the time it streams and closes it or is it always open for the full lifetime of the app?
@bootsector13
@bootsector13 8 ай бұрын
what I did for the solution was I saved the result in the browsers local storage as json format while the page is on server rendered then retrieve that result when the page is rendered as wasm.
@EricKing
@EricKing 8 ай бұрын
Is there no way to turn off prerendering globally? Or do you have to do it component by component? edit: Found this in the docs. Lame. "To disable prerendering for the entire app, indicate the render mode at the highest-level interactive component in the app's component hierarchy that isn't a root component."
@chrisgoetz9330
@chrisgoetz9330 8 ай бұрын
Yes - in the server project in Components > App.razor find the body tag. Inside that tag you will find or possibly . You can change the render mode within the Routes component globally. An example would be: . If you have configured your project to use authentication for individual accounts, you will want to make this change in the RenderModeForPage method at the bottom of the App.razor file instead.
@FearGod123
@FearGod123 8 ай бұрын
Great tutorial. Very helpful. Thank you
@MrDinakdakan
@MrDinakdakan 8 ай бұрын
patric you using blazor modal? blazor modal not working no new blazor app, client cant see cascadingparamter in server
@Tommyt212002
@Tommyt212002 8 ай бұрын
Patrick can you please do video on the Fluent Blazor dialog service? Its been so confusing how to correctly implement.
@markharby180
@markharby180 8 ай бұрын
Like you say, I'm sure Microsoft had a good reason to bring in all of this rendering mayhem, but I'll be brutally honest it has turned me right off Blazor, you can now waste hours tracking down a problem that is not there. I have been evaluating UI frameworks (Radzen, Mud, Syncfusion) and have been hitting all sorts of problems and blocks, really frustrating. Thanks for trying to bring some clarity but I can sense by your frustration in trying to explain it that this is still not clear.
@m4r10x2
@m4r10x2 8 ай бұрын
Same here, my conclusion is to go webassembly mode only and Tailwind for UI. That should give full flexibility without too much magic
@thibaudgallanddemanneville174
@thibaudgallanddemanneville174 8 ай бұрын
Am I missing something if instead of calling the api in the OnInitializeAsync I'm calling it in the OnAfterRenderAsync ?
@volibita8902
@volibita8902 8 ай бұрын
This is a bid issue( from my opinion), In my blazor server project i have a cascade parameter in mainlayaout and the call to db for receiving data makes twice. i think many developers deactivate prerender in net8 blazor becouse the benefits are less than the damage this logic does.
@TrOgaN_
@TrOgaN_ 8 ай бұрын
Im not sure why they didn't just disable prerenering when the reneder mode is set to webassembly, I guess that's too hard for em!
@minashokrallameichael5998
@minashokrallameichael5998 8 ай бұрын
Now I will call the API twice one from server and one from client, correct?
@okcharles7
@okcharles7 7 ай бұрын
Yes. Once for prerendering, another for client side (real) rendering. With this setup, your server gives web crawlers a pre-rendered page with data filled up and it may help SEO, which used be one of the biggest challenge for all SPAs (not limited to Blazor)
@tfarrag1981
@tfarrag1981 8 ай бұрын
I face this problem in the fist day of using balzor 8.0 . Is thier any way to gobally stop preredering in client project
@Akustik
@Akustik 8 ай бұрын
private IComponentRenderMode renderMode = new InteractiveWebAssemblyRenderMode(prerender: false); private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account") ? null : renderMode;
@Together4Ever96
@Together4Ever96 8 ай бұрын
Great tutorial. Can you make Video how to deploy Blazor Web App on Azure ? :)
@cfeze
@cfeze 7 ай бұрын
PageTitle doesn't work when Prerendering is false, has anyone found a solution to this?
@pezhmanpiramoun2997
@pezhmanpiramoun2997 7 ай бұрын
important !
@dasfahrer8187
@dasfahrer8187 8 ай бұрын
Haha, this exact behavior happened to me the other day. I was like 😕❔❓⁉
@richardaubin1951
@richardaubin1951 8 ай бұрын
Just cache the first response.
@AlexandreRizzo-p2u
@AlexandreRizzo-p2u 8 ай бұрын
Hi, Patrick! I already had notice this behavior. I found another video on how to avoid this (kzbin.info/www/bejne/p4KcYqWagsx8g68). Hope it helps!
@randypenajimenez3893
@randypenajimenez3893 4 ай бұрын
Blazor Server Side all day.
@alex.nolasco
@alex.nolasco 8 ай бұрын
🤦‍♂
@navirbox4913
@navirbox4913 7 ай бұрын
I just realized something with these kind of videos. They way you put the title and say nothing about the content in the description makes it so difficult for someone who's actually trying to find the solution to the problem explained in said video. Do you prefer short-term views by shock value or long-term views from people who actually searched for the solution? Food for thought.
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,7 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 3 МЛН
CRUD with the Blazor WebAssembly Render Mode in .NET 8 🔥
50:49
Create Cascading Dropdowns with Blazor in .NET 8 🔥
22:12
Patrick God
Рет қаралды 8 М.
How to use FlutterFlow and Cursor AI Code Editor
28:58
Nocode Solutions
Рет қаралды 166
164. What is the Future of Blazor? Should I Learn Blazor?
22:32
IAmTimCorey
Рет қаралды 57 М.
Beautiful Sortable Drag & Drop Lists for your Blazor Apps
32:11
The Blazor Competitor is Here!
15:08
Nick Chapsas
Рет қаралды 74 М.