dotnet/aspnetcore

.NET 9 - Blazor Web App - Global Server Rendering with Individual Accounts not working

ekomsctr opened this issue · 2 comments

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Just created a brand new Blazor Web App (Global Server Render Mode) project, but i found that both the Login and Register page (in general every page that uses Identity) does not work correctly as there is no User after the login.

Only if i do a full page refresh, then the authentication wires up and starts working again.

Expected Behavior

The NavigationManager correctly works as the current RenderMode is set to null in the App.razor

Steps To Reproduce

Spin un a brand new Blazor Web App with the following project creation settings:
Image

And you will get this exception right after the login (or registration), when the IdentityRedirectManager tries to redirect you to the next page (IdentityRedirectManager.cs:31)
Image

Exceptions (if any)

Microsoft.AspNetCore.Components.NavigationException
HResult=0x80131500
Message=Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown.
Source=Microsoft.AspNetCore.Components.Server
StackTrace:
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.NavigateToCore(String uri, NavigationOptions options)
at Microsoft.AspNetCore.Components.NavigationManager.NavigateToCore(String uri, Boolean forceLoad)
at Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(String uri, Boolean forceLoad, Boolean replace)
at TestAuth.Components.Account.IdentityRedirectManager.RedirectTo(String uri) in C:\my\work\cdesign\repo\HyperionNext\TestAuth\Components\Account\IdentityRedirectManager.cs:line 31
at TestAuth.Components.Account.IdentityRedirectManager.RedirectTo(String uri, Dictionary`2 queryParameters) in C:\my\work\cdesign\repo\HyperionNext\TestAuth\Components\Account\IdentityRedirectManager.cs:line 40
at TestAuth.Components.Account.Pages.Register.d__12.MoveNext() in C:\my\work\cdesign\repo\HyperionNext\TestAuth\Components\Account\Pages\Register.razor:line 96
at Microsoft.AspNetCore.Components.ComponentBase.d__30.MoveNext()

.NET Version

9.0.100

Anything else?

Visual Studio 2022 17.12.0

Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4

@ekomsctr thanks for contacting us.

That exception is thrown and caught by the framework internally during prerendering to handle redirects. You can configure the debugger to avoid breaking on it.

@halter73 do you know why the debugger still breaks in this case? 

Dupe of #53996