Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Originally reported as a problem with the Radzen.Blazor component library which we maintain. After troubleshooting it turned out that no event handlers are firing (no exceptions or any other problems).
I tested without Radzen.Blazor and managed to reproduce the problem with a vanilla button click handler taken from the Counter.razor component that comes from the default application template.
For some reason event handlers defined in the layout do not fire out of the box.
Expected Behavior
I expected event handlers in layouts to work as in earlier Blazor and .NET versions. Maybe some configuration is missing (related to the new mixed rendering model).
Steps To Reproduce
- Create a new .NET 8 Blazor application by running
dotnet new blazor -o BlazorNET8
- Open
Components/MainLayout.razor
. - Delete everything and paste
@inherits LayoutComponentBase <div class="page"> <div class="sidebar"> <NavMenu /> </div> <main> <div class="top-row px-4"> <p role="status">Current count: @currentCount</p> <button class="btn btn-primary" @onclick="IncrementCount">Click me</button> <a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a> </div> <article class="content px-4"> @Body </article> </main> </div> <div id="blazor-error-ui"> An unhandled error has occurred. <a href="" class="reload">Reload</a> <a class="dismiss">🗙</a> </div> @code { private int currentCount = 0; private void IncrementCount() { currentCount++; } }
- Run the application and try clicking the Click me button in the header. The displayed counter value remains 0 instead of incrementing. In .NET 7 this works as expected.
Exceptions (if any)
No response
.NET Version
8.0.100-rc.1.23455.8
Anything else?
I am testing on macOS (M1, Ventura 13.4.1).