0

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

H H
  • 263,252
  • 30
  • 330
  • 514

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
  • 41,195
  • 5
  • 76
  • 113