0

Why are Blazor lifecycle methods getting executed twice? what is the benefit of this feature?

Henk Holterman
  • 250,905
  • 30
  • 306
  • 490

1 Answers1

2

They are executed twice because your application is pre-rendering. Note that while your application is pre-rendering JavaScript is not available. To opt for pre-rendering, set the render-mode attribute of the component Html tag helper to "ServerPrerendered", like the following:

<component type="typeof(App)" render-mode="ServerPrerendered" />

If you don't want pre-rendering, set the render-mode attribute to "Server"

That was the short answer. If you want a full-blown description as to why you need pre-rendering, what consideration you should take into account, etc., look up the subject in the docs...

enet
  • 34,056
  • 4
  • 55
  • 89