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

  Рет қаралды 13,873

Patrick God

Patrick God

Күн бұрын

🚀 Join the .NET Web Academy: learn.dotnetwe...
💖 Support me on Patreon for exclusive source code access: / _patrickgod
🚀 Get the .NET 8 Web Dev Jump-Start Course for FREE: dotnet8.patric...
🐦 Let's get social on Twitter/X: / _patrickgod
🔗 Let's connect on LinkedIn: / patrickgod
#DotNet #Blazor #AspNetCore

Пікірлер: 47
@markusn4614
@markusn4614 6 ай бұрын
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 6 ай бұрын
do you have an example project you can share with this approach ?
@Wouldntyouliketoknow2
@Wouldntyouliketoknow2 5 ай бұрын
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?
@chairmakerPete
@chairmakerPete 3 ай бұрын
Useful info. I'm staying away from Blazor web assembly for a few more versions in the hope it'll settle down.
@cristovaomorgado
@cristovaomorgado 6 ай бұрын
WOW I've been having this issue and never understood the why! GREAT!!!!!
@poteb
@poteb 6 ай бұрын
Another reason I like the clean WASM+hosted model a lot more than this confusion mess.
@margosdesarian
@margosdesarian 6 ай бұрын
Great Video Patrick, these sort of things, where information falls between the cracks, it is really great to explain it
@slopapa
@slopapa 6 ай бұрын
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 6 ай бұрын
Blazor Server != Blazor SSR.
@okcharles7
@okcharles7 5 ай бұрын
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.
@gordantadic5156
@gordantadic5156 6 ай бұрын
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 6 ай бұрын
YEP- JS Nightmare !
@orterves
@orterves 4 күн бұрын
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
@classiccomputing
@classiccomputing 6 ай бұрын
Great catch! I saw this problem and didn’t know what was going on!
@bootsector13
@bootsector13 5 ай бұрын
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.
@schreiber-it-consulting
@schreiber-it-consulting 6 ай бұрын
Great video. Thanks! Just one question: Why not just use PersistentComponentState?
@Krasipeace
@Krasipeace 6 ай бұрын
omg... finally figured out the freaking bug! Thank you so much!
@markharby180
@markharby180 6 ай бұрын
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 6 ай бұрын
Same here, my conclusion is to go webassembly mode only and Tailwind for UI. That should give full flexibility without too much magic
@rmbl349
@rmbl349 2 ай бұрын
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?
@volibita8902
@volibita8902 6 ай бұрын
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.
@kurdishfreeman7568
@kurdishfreeman7568 6 ай бұрын
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.
@FearGod123
@FearGod123 6 ай бұрын
Great tutorial. Very helpful. Thank you
@EricKing
@EricKing 6 ай бұрын
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 6 ай бұрын
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.
@TrOgaN_
@TrOgaN_ 6 ай бұрын
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!
@k3dare
@k3dare 6 ай бұрын
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 ?
@Tommyt212002
@Tommyt212002 6 ай бұрын
Patrick can you please do video on the Fluent Blazor dialog service? Its been so confusing how to correctly implement.
@thibaudgallanddemanneville174
@thibaudgallanddemanneville174 6 ай бұрын
Am I missing something if instead of calling the api in the OnInitializeAsync I'm calling it in the OnAfterRenderAsync ?
@Together4Ever96
@Together4Ever96 6 ай бұрын
Great tutorial. Can you make Video how to deploy Blazor Web App on Azure ? :)
@pezhmanpiramoun2997
@pezhmanpiramoun2997 4 ай бұрын
important !
@MrDinakdakan
@MrDinakdakan 6 ай бұрын
patric you using blazor modal? blazor modal not working no new blazor app, client cant see cascadingparamter in server
@cfeze
@cfeze 5 ай бұрын
PageTitle doesn't work when Prerendering is false, has anyone found a solution to this?
@tfarrag1981
@tfarrag1981 6 ай бұрын
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 6 ай бұрын
private IComponentRenderMode renderMode = new InteractiveWebAssemblyRenderMode(prerender: false); private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account") ? null : renderMode;
@minashokrallameichael5998
@minashokrallameichael5998 6 ай бұрын
Now I will call the API twice one from server and one from client, correct?
@okcharles7
@okcharles7 5 ай бұрын
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)
@navirbox4913
@navirbox4913 5 ай бұрын
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.
@dasfahrer8187
@dasfahrer8187 6 ай бұрын
Haha, this exact behavior happened to me the other day. I was like 😕❔❓⁉
@richardaubin1951
@richardaubin1951 6 ай бұрын
Just cache the first response.
@randypenajimenez3893
@randypenajimenez3893 2 ай бұрын
Blazor Server Side all day.
@AlexandreRizzo-p2u
@AlexandreRizzo-p2u 6 ай бұрын
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!
@alex.nolasco
@alex.nolasco 6 ай бұрын
🤦‍♂
Самое неинтересное видео
00:32
Miracle
Рет қаралды 2,7 МЛН
My daughter is creative when it comes to eating food #funny #comedy #cute #baby#smart girl
00:17
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 62 МЛН
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 49 МЛН
Why We Choose Blazor over React and Vue: Matt Jones
40:23
Techlahoma
Рет қаралды 7 М.
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 158 М.
Beautiful Sortable Drag & Drop Lists for your Blazor Apps
32:11
The New .NET 9 HybridCache That You Must Upgrade To!
14:34
Nick Chapsas
Рет қаралды 51 М.
CRUD with the Blazor WebAssembly Render Mode in .NET 8 🔥
50:49
Самое неинтересное видео
00:32
Miracle
Рет қаралды 2,7 МЛН