Skip to content

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

Open
@Manish3177

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

Metadata

Labels

bugSomething isn't workingtrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions