This happens because of Pre-rendering
of blazor components
This is default behavior in
Blazor pre-renders the component on the server, i.e. calls OnInitialized (OnInitializedAsync) method on the server,
generates the HTML for the component,
returns the generated HTML to the browser
After this
On the client side (in browser), Blazor Initialize the component again for the interactivity, thus calls the OnInitialized (OnInitializedAsync) method again
Disable the pre-rendering for the component
You can follow this youtube video for in-depth explanation and solution
How to Fix the Issue with Blazor Prerendering - OnInitialized Gets Called Twice
No comments yet. Be the first to leave a comment