Skip to content

Continuous browser reloading while navigating within AuthorizeView razor page #52686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Sureshrajan-18 opened this issue Dec 9, 2023 · 2 comments
Closed
1 task done
Assignees
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@Sureshrajan-18
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In our Blazor .NET 8 server-mode application, we have integrated an Authorize razor page. However, when navigating within the Authorize razor page, the browser continuously reloads.

We have utilized the AuthorizeRouteView to check the user is authorized or not.

Expected Behavior

The navigation within the Authorize razor page should render correctly without any browser reloading issues.

Steps To Reproduce

Please find the issue replicated GitHub sample from the below link.

https://github.com/Sureshrajan-18/Blazor_.NET8-AuthorizeRouteView

When navigating within the Auth Required, Register, and Login razor pages, you will notice the browser continuously reloading.

Exceptions (if any)

No response

.NET Version

dotnet version 8

Anything else?

No response

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Dec 9, 2023
@qwertybba
Copy link

The issue affects a wide community, so I hope Microsoft fixes it as soon as possible

@halter73
Copy link
Member

halter73 commented Apr 5, 2024

I submitted a PR to the repro project to fix the continuous reloading: Sureshrajan-18/Blazor_.NET8-AuthorizeRouteView#1

As I note in the PR's description, the logic in AccountLayout.razor intentionally calls NavigationManager.Refresh(forceReload: true) to force a transition from dynamic back to static rendering. If you put a breakpoint there without the changes from the PR, you'll see it repeatedly get hit for reach reload.

The account pages are intended to be used with static rendering where the HttpContext is available so the SignInManager can use the IHttpContextAccessor to do things like sign in and out via server-side authentication schemes which rely on being able to set 302 responses to redirect.

@SteveSandersonMS Just opened #54948 which will add a @staticroute directive in .NET 9 (final name to be determined) that we will use on the account pages to make this clearer, and harder to mess up if you refactor your App.razor. The RenderModeForPage logic will go away.

@halter73 halter73 closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

3 participants