SetUserAgentOverrideAsync Iframe not work #4849
drRobertDev
started this conversation in
General
Replies: 1 comment
-
Converting to discussion as cefsharp is just a wrapper. You'd have to work out if the problem is in chromium or in CEF and raise an issue in the relevant issue tracker. Read the first few paragraphs of https://github.com/cefsharp/CefSharp/wiki/General-Usage for background. Have you considered puppeteer sharp? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there an existing issue for this?
CefSharp Version
126.2.70
Operating System
Windows 11
Architecture
x64
.Net Version
.net 8
Implementation
OffScreen
Reproduction Steps
UserAgentMetadata AgentMetaData =>
new()
{
Brands = new List()
{
new UserAgentBrandVersion { Brand = "Not/A)Brand", Version = "8" },
new UserAgentBrandVersion { Brand = "Chromium", Version = "126" },
new UserAgentBrandVersion { Brand = "Google Chrome", Version = "126" },
},
FullVersion = "126.0.0.0",
Platform = "Windows",
PlatformVersion = "Win64",
Architecture = "x64",
Model = "",
Mobile = false,
};
using var devToolsClient = _webController.GetDevToolsClient();
await devToolsClient.Network.SetUserAgentOverrideAsync(BrowserAgentChrome, userAgentMetadata: WebHelper.AgentMetaData);
await devToolsClient.Emulation.SetUserAgentOverrideAsync(BrowserAgentChrome, userAgentMetadata: WebHelper.AgentMetaData);
Look like not work with Iframe on page, then will show cef base value sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126" instead sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126" on iframe calls
.html load with exspected header, .js load with wrong header.
i tried also with _webController.FrameLoadEnd += Browser_FrameLoadEnd;
private static async void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
var browser = (ChromiumWebBrowser)sender;
var frameDevToolsClient = e.Browser.GetDevToolsClient();
await frameDevToolsClient.Network.SetUserAgentOverrideAsync(BrowserAgentChrome, userAgentMetadata: AgentMetaData);
await frameDevToolsClient.Emulation.SetUserAgentOverrideAsync(BrowserAgentChrome, userAgentMetadata: AgentMetaData);
}
but look like not apply on iframe
Expected behavior
sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"
Actual behavior
sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126"
Regression?
not work in previous versions
Known Workarounds
nope
Does this problem also occur in the CEF Sample Application
Yes using WPF/OffScreen command line args
Other information
No response
Beta Was this translation helpful? Give feedback.
All reactions