Skip to content
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

[Blazor] Intercept navigation from inside iframe #47645

Open
1 task done
rhodon-jargon opened this issue Apr 11, 2023 · 2 comments
Open
1 task done

[Blazor] Intercept navigation from inside iframe #47645

rhodon-jargon opened this issue Apr 11, 2023 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components
Milestone

Comments

@rhodon-jargon
Copy link

rhodon-jargon commented Apr 11, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When a link (<a> tag) is clicked within an iframe but its target is the parent frame (the one running blazor), it is treated as external navigation (e.g. blazor has to reload) even if its href is within the base tag.
I have already tried multiple ways to fix this, like setting the target to _top or _parent, or adding a <base> tag to the iframe (with the same href as the parent's <base> tag, and/or with a target of _top or _parent instead of the <a> tag).
I understand this might not be possible to prevent when the iframe is a different origin, but the bug also occurs when setting the contents of the iframe using the srcdoc attribute.
I have only tested this in Blazor Webassembly, though I suspect Blazor Server works the same way.

Expected Behavior

When an internal link is clicked within the iframe, the internal router of blazor handles the redirection without reloading if possible.

Steps To Reproduce

Create an iframe with the srcdoc set to <a href="/some-internal-link">Click</a>. Clicking the link reloads the page.
I also made a sample project based on the Webassembly template: FrameNavigation. The problem can be seen on the Counter page.

Exceptions (if any)

No response

.NET Version

7.0.202

Anything else?

Context: I am using an iframe to isolate (trusted) user content from the main layout, so that the user can supply custom CSS and HTML without affecting the main page. However, the user content should be able to link to other user content/pages.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Apr 11, 2023
@MackinnonBuck MackinnonBuck added this to the Backlog milestone Apr 11, 2023
@ghost
Copy link

ghost commented Apr 11, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@MackinnonBuck MackinnonBuck modified the milestones: Planning: WebUI, Backlog Dec 4, 2023
@ghost
Copy link

ghost commented Dec 4, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 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

5 participants
@MackinnonBuck @wtgodbe @mkArtakMSFT @rhodon-jargon and others