MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: When [Frame]NavigationStarting event handler runs, args.Request.Headers never has Referer header

Open
#4,766 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

When [Frame]NavigationStarting event handler runs, args.Request.Headers doesn't have the Referer header even if the actual request to the target URL has it. Specifically, args.Request.Headers.Contains("Referer") returns false. We have some logic in [Frame]NavigationStarting event handler that uses the Referer header to decide (a) whether to set args.Cancel = true and (b) whether to a UI (MessageBox) to the user indicating that the navigation was cancelled.

This is particularly odd given that the request is dispatched before the event handler actually runs as noted in #4765. Also, for what it's worth, the header is present in the WebResourceRequested event handler but we are unable to use because it's unreliable as noted in #4689.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

127.0.2651.105

SDK Version

1.0.2535.41

Framework

Winforms

Operating System

Windows 11

OS Version

10.0.22631.4037

Repro steps

Set up a [Frame]NavigationStarting event handler to record/log the value of args.Request.Headers.Contains("Referer"). Attempt a few navigations while recording network traffic with dev tools or Fiddler. Observe the recorded/logged value is always false even if some navigations have the Referer header.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

AB#53476110

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.