In Blazor .Net 8 I cannot implement OnAfterRenderAsync. It gives me the error “No suitable method found to override”.
I thought my project was corrupted so I created a new test project:
Blazor Web App
.Net 8
Authentication: none
Auto (Server and WebAssembly)
Per page/component
On Home.razor tried to add OnAfterRenderAsync and still get the same error. Here is the home page code. I tried InteractiveServer with prerendering and without prerendering. Same error.
@page "/"
@rendermode InteractiveServer
@* @rendermode @(new InteractiveServerRenderMode(prerender: false)) *@
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.
@code {
protected override async Task OnAfterRenderAsync()
{
}
}
Has anyone else had this issue? I even updated to the latest Visual Studio before creating the new test project.