Thanks Andrew, your example works for me too.
In my project I'm using Blazor.Server and .NET5.0 Maybe it's because of the configuration.