Thank you for the valuable information. I have spent many hours to resolve this problem
What about PersistentComponentState? I think is more SEO friendly. You can use the PersistentComponentState implementation, so you can set prerendering to true, but getting to call Database/intensive operations once. Calling the OnInitialized method is not really a problem, the problem comes when data is requested twice from DB.
I love Blazor 8, but MS needs to do a better job of dog fooding their stuff. When I ported my Blazor Server app to the Blazor Web template, I had this same issue. Took me a good hour of internet research to find this same workaround. For my app, I set this globally on the routes component, as it is a SPA.
Wonderful !! Thank you for the valuable information. It will help me solve many problems.
I agree, it's the worst when calling LoadData from DB and the function got recalled again.
Very helpful video, thanks!
Nice. I'm sure I will use this soon. You have also lost a l ot of weight, whatever u are doing is working. Great job man
the biggest two issues of blazor wasm are : - startup time (caching enabled - empty App.razor - empty Program.cs) 1.5s to render an empty page. - hot reloading issues during development is a nightmare I've tried everything that I could to optimize the startup time for a completely empty blazor wasm app, 1.5s is what i get. So with a real application the wait time can be +4 or +5 seconds which is not acceptable at all :(
On a fresh new application based on the default Blazor Web App Template, I never see the "Loading..." message at 1:28, and at Network tab, the request shows as: Status (pending), not immediately 200 as in your demo. Can anyone help me?
What about presistingcomponent state that’s a functionality from the framework
As an aside you mention at 02:11 that we can remove @attribute [StreamRendering] because you have put in @rendermode InteractiveServer but don't they do different things? StreamRendering displays the "Loading..." whilst waiting for the server to complete the OnInitialized logic. Interactive simply allows the page to respond to events. Maybe it was just your phrasing but it sounded as if you can't use both together?
nice workaround. I'm sure I'll use it
For whatever reason, I couldn't reproduce this behaviour using the Blazor Web App with server interactivity location set to Per page/component. The breakpoint set on the OnInitializedAsync method was not hit twice but once. Did you miss something or I missed something?
thanks for a big heads-up
Super stuff, thanks!
For this issue,I have discussed the PersistComponentState approach in detail https://youtu.be/qQ91rdMgIMM
Unfortunately, I think disabling/bypassing Pre-rendering harms SEO and prevents search engines from seeing/indexing page content, even though the solution is useful from a UX point of view. I eventually had to re-enable it because search engines saw pages as empty. Are you aware of a better solution that still allows prerendering to remain enabled?
You can actually move the data load and delay into onafterrender instead oninit, first render only of course
how can i sync between sqlite on mobile offline and remote database (restapi with sql server ) ?
@Codewrinkles