Closed iguanaware closed 5 years ago
Thanks for contacting us, @iguanaware.
In Preview8 pre-rendering is a separate render than the actual rendering. So that's expected.
In Preview 9 we don't run the OnAfterRenderAsync
as part of pre-rendering.
@mkArtakMSFT I think this design should be looked at again. currently when somebody wants to use pre-rendering and makes some database calls or http calls that won't be cheap, it will be really painful.
I'm also pretty sure that there is no need to actually call initalization logic twice. I mean react does not need it, neither does angular.
This "by design" thing will have a huge impact for users that want to improve some razor pages with interactive blazor components. I know it's probably not easy to support, but at least it should've been put to the backlog/discussed instead of closed as "by design".
Related to #11876 (8 3.0.100-preview8-013656) It's not calling the methods twice on "a" component. It actually creates two components that each have their events fired. But the prerender one fails to get dotnet references.
Remove Html.RenderStaticComponentAsync and the problem goes away.
The bigger problem is that OnAfterRenderAsync is firing on the prerendering pass
Reproduce:
dotnet new blazorserver
add to Index.razor
Below is the output (OnAfterRenderAsync
there appears twice)