Skip to content

Add location.reload on rejected Blazor reconnection to ReconnectModal… #60753

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

oroztocil
Copy link
Member

@oroztocil oroztocil commented Mar 5, 2025

As reported here with the new reconnection UI component in the Blazor project template, the client does not automatically reconnect after a developer stops and restarts the app (e.g. in Visual Studio or using dotnet CLI) without closing or refreshing the browser tab.

I tested it in .NET 9 and found that this workflow never worked with customized reconnection UI.

I investigated the differences in implementation of UserSpecifiedDisplay (used when user has customized reconnection UI) and DefaultReconnectDisplay (used otherwise) and found that the latter has additional call to location.reload when it gets rejected by the Blazor server during reconnection attempt. This is what happens when another instance of the app restarts on the same port. The reload is what enables the development workflow described in the issue.

I added such call to the ReconnectModal component to match the expected behavior.

Fixes https://github.com/dotnet/AspNetCore-ManualTests/issues/3489

@Copilot Copilot AI review requested due to automatic review settings March 5, 2025 13:07
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Mar 5, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request updates the reconnection logic in the Blazor reconnection UI to automatically reload the page when a reconnection attempt is rejected, mirroring the behavior of the default reconnection display.

  • Added a new condition to handle the "rejected" state
  • Calls location.reload() to force a page refresh upon rejection

Reviewed Changes

File Description
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Layout/ReconnectModal.razor.js Added condition for "rejected" state to invoke location.reload()

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@oroztocil oroztocil requested a review from a team March 5, 2025 13:07
@oroztocil oroztocil enabled auto-merge (squash) March 5, 2025 13:25
@oroztocil oroztocil merged commit 83a186c into main Mar 5, 2025
27 checks passed
@oroztocil oroztocil deleted the oroztocil/fix-blazor-reconnect-ui-reload branch March 5, 2025 16:53
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview3 milestone Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants