Blazor-Blogs icon indicating copy to clipboard operation
Blazor-Blogs copied to clipboard

Retargeting Blazor-Blogs to .NET 10 failed with a System.InvalidOperationException at runtime.

Open CancanTang opened this issue 6 months ago • 1 comments

Just a heads up !

After retargeting Blazor-Blogs to .NET10 using dotnet-sdk-10.0.100-preview.5.25272.110, the app throws the following errors at runtime: System.InvalidOperationException: IdentityRedirectManager can only be used during static rendering System.InvalidOperationException: 'RemoteNavigationManager' already initialized

Upon investigation, the issue was caused by the change described in the following release note: https://learn.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-10.0?view=aspnetcore-9.0#navigationmanagernavigateto-no-longer-throws-a-navigationexception

Calling NavigationManager.NavigateTo during static SSR no longer throws a NavigationException. Instead, it behaves consistently with interactive rendering by performing the navigation without throwing an exception. Code that relied on NavigationException being thrown should be updated. For example, in the default Blazor Identity UI, the IdentityRedirectManager previously threw an InvalidOperationException after calling RedirectTo to ensure it wasn't invoked during interactive rendering. This exception and the [DoesNotReturn] attributes should now be removed.

For more details, please refer to dotnet/aspnetcore#62171.

CancanTang avatar Jun 11 '25 05:06 CancanTang

Thanks for this! Will do then when .NET10 is released.

ADefWebserver avatar Jun 11 '25 12:06 ADefWebserver