How to Fix the Issue with Blazor Prerendering - OnInitialized Gets Called Twice - Abhay Prince

Опубликовано: 09 Апрель 2026
на канале: Abhay Prince
6,049
146

There is an issue with Blazor Interactive Component Pages (InteractiveServer, InteractiveWebAssembly, and InteractiveAuto), Prerendering is enabled by-default, which causes OnInitialized(Async) to be executed twice, (first on the Server and then on the Client), which can be expensive and error-prone in some of the cases if not dealt properly.
In this video I explained, What and How to fix it.
This was same with Previous versions of the Blazor as well with prerendering enabled.
The only change with .Net 8 blazor is that, they have enabled prerendering by-default.

Free Source Code
https://www.buymeacoffee.com/abhaypri...

How to fix OnIntialized Method getting called twice in Blazor
How to Persist Component State in Blazor Prerendering with Interactive Blazor Component Pages
On Initialized method executing twice in Blazor Server
On Initialized method executing twice in Blazor WebAssembly
On Initialized method executing twice in Blazor InteractiveSever
On Initialized method executing twice in Blazor InteractiveWebAssembly
On Initialized method executing twice in Blazor InteractiveAuto
How to fix the blazor oninitialzied issue with multiple calls

If you like my work and want to support me, buy me a coffee https://www.buymeacoffee.com/abhayprince

#blazor #blazorserver #blazorserverproject #blazorproject #dotnet #miniproject #csharp #tutorial #stepbystep #codewalkthrough #appprogramming #softwaredevelopment #backenddevelopment #frontenddevelopment #visualstudio #programminglanguages #learntocode #abhayprince #microsoft #webdevelopment #google #webproject #blogapp #blog #blogprojectdevelopment #blogwebapp #blogappdevelopment #newblazor #blazorssr #dotnet8 #blazorstremrendering #blazorgrid #blazorapp