The comment here states "These methods are only called one time when the component is first instantiated." This is not actually true in a Pre-rendered scenario, which is the default for Blazor Server. Therefore, people may inadvertently put initialisation logic such as data loading, or delegate hooks, into this method, and not realise that it gets called twice.
It might make sense to put an info box with the caveat explaining that it can get called twice, and link to this page - and it may be useful to have a full example explaining an approach to loading initialisation data in this context.
See this issue for background: https://github.com/dotnet/aspnetcore/issues/18815
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@Webreaper ... Thanks for writing in on this. I'm in the process of moving content out of the hosting models topic (where this scenario is covered) simply because it's too distracting there for early coverage on hosting models. The idea is to move the hosting model configuration coverage out into a new topic called ... drum roll plz 🥁 ... Hosting model configuration.
You inquired on this scenario at the perfect time. I also now believe that the coverage on Stateful reconnection after prerendering and Detect when the app is prerendering should be in the Lifecycle methods topic. However, they shouldn't IMO be shoehorned right in at the top of the doc where OnInitializedAsync is covered. I think they should be covered at the end of the topic with both sections cross-linked into the Component initialization methods (OnInitializedAsync) section.
I'm doing that right now, and I'll ping u on that PR shortly. Thanks again for writing in on this.
Thanks for the quick turnaround. Timing is everything!