Skip to content

[Blazor] Emit action attribute when not explicit. #51130

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 11 commits into from
Oct 11, 2023

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Oct 4, 2023

This change updates the server rendering logic to always emit an absolute URL for a form action when none is specified explicitly.

Description

When as part of rendering a form, the developer does not explicitly add an action attribute, the framework will automatically generate one with the value of the current request URL.

Fixes #51118

Customer Impact

When enhanced navigation is active, the URL might change while an update to the page is in progress. In such situations, if the user clicks a button and submits a form, the form might incorrectly post to the wrong URL, as the page URL might have already been updated.

Given that when the URL updates on the document is not a behavior, we have control over, we have to account for this, and to prevent it, we make sure that we always generate forms with an action attribute, which is unambiguous.

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

Risk

  • High
  • Medium
  • Low

The fix is to detect forms without an action attribute and emit it to the current URL. This is correct in all cases and is unambiguous.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

When servicing release/2.1

  • Make necessary changes in eng/PatchConfig.props

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Oct 4, 2023
@javiercn javiercn force-pushed the javiercn/blazor-web-enhanced-form-nav-action branch from 31214c2 to 18387c2 Compare October 4, 2023 19:15
@javiercn javiercn force-pushed the javiercn/blazor-web-enhanced-form-nav-action branch from 18387c2 to 6ba91b0 Compare October 10, 2023 15:21
@SteveSandersonMS SteveSandersonMS self-requested a review October 10, 2023 15:34
Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Since you've confirmed you'll deal with the duplicate history entries thing, I'm happy to approve now and leave it with you to address the final bits.

@javiercn javiercn force-pushed the javiercn/blazor-web-enhanced-form-nav-action branch from 6ba91b0 to 5759f3e Compare October 10, 2023 15:53
@javiercn javiercn marked this pull request as ready for review October 10, 2023 17:42
@javiercn javiercn requested a review from a team as a code owner October 10, 2023 17:42
@javiercn javiercn added the Servicing-consider Shiproom approval is required for the issue label Oct 10, 2023
@ghost
Copy link

ghost commented Oct 10, 2023

Hi @javiercn. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

@mkArtakMSFT mkArtakMSFT added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Oct 11, 2023
@ghost
Copy link

ghost commented Oct 11, 2023

Hi @javiercn. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@javiercn javiercn force-pushed the javiercn/blazor-web-enhanced-form-nav-action branch from 31362f1 to eee3f01 Compare October 11, 2023 11:12
@mkArtakMSFT mkArtakMSFT merged commit eb73b70 into release/8.0 Oct 11, 2023
@mkArtakMSFT mkArtakMSFT deleted the javiercn/blazor-web-enhanced-form-nav-action branch October 11, 2023 15:53
@ghost ghost added this to the 8.0.0 milestone Oct 11, 2023
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 Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants