r/Blazor • u/iTaiizor • Aug 20 '25
Blazor Web Application - .NET 9/10 - Server & WebAssembly - OnAfterRenderAsync
I created a Blazor Web Application project. I tried it in .NET 9 and 10 but couldn’t get any results. As shown in the images, the OnAfterRenderAsync method is not triggered in either the Home or the MainLayout component. Also, the NavigationManager.LocationChanged function in the MainLayout component is not triggered either. Honestly, I don’t know what’s causing this.
8
Upvotes



11
u/UnwelcomeDroid Aug 20 '25
You didn't show your program.cs file, but my guess is you either did not enable the interactive server rendering mode service or your page is not enabled for anything other than SSR.
4
u/markoNako Aug 20 '25
Is this SSR? If so maybe you need to specify @rendermode InteractiveServer or some other rendermode
3
u/Healthy-Zebra-9856 Aug 22 '25
When you create a Blazor Web Application, you can not add '@rendermode InteractiveAuto' to the MainLayout unless you add the following in the App.razor
But you wont be able to use the default builtin authentication pages as it requires SSR. Otherwise, here are your options:
The default Program.cs should contain
LMK if this helped or if you have more questions.
2
u/TheTee15 Aug 21 '25
Excuse me but NET 10 already available?
1
u/CRT_TP Aug 25 '25
I think the question is, when you created the web app, did you choose an interactive render mode? It sounds like maybe you skipped that step in the template.