Why are Blazor lifecycle methods getting executed twice? what is the benefit of this feature?
Asked
Active
Viewed 258 times
0
-
1– A Abdulbawab Jul 29 '20 at 13:09
-
Can you share some code, what is getting executed twice? – Umair Jul 29 '20 at 13:27
-
Does this answer your question? [Why are Blazor lifecycle methods getting executed twice?](https://stackoverflow.com/questions/58075628/why-are-blazor-lifecycle-methods-getting-executed-twice) – H H Jul 30 '20 at 09:30
-
Or https://stackoverflow.com/q/60996170/60761 – H H Jul 30 '20 at 09:32
1 Answers
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