mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Bug with SetUserAgent #366
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DiefBell on GitHub (Jul 23, 2019).
Originally assigned to: @GregorBiswanger on GitHub.
Using the following code, which according to what I can find online, should but doesn't set the UserAgent header accordingly, and instead uses the default UserAgent string.
var mainWindow = await Electron.WindowManager.CreateWindowAsync(options); mainWindow.WebContents.Session.SetUserAgent("ModX"); mainWindow.OnReadyToShow += () => { mainWindow.Show(); };@GregorBiswanger commented on GitHub (Jul 26, 2019):
The documentation from native electron says: "This doesn't affect existing
WebContents, and eachWebContentscan usewebContents.setUserAgentto override the session-wide user agent."(see https://electronjs.org/docs/api/session).
Maybe that's your problem?
@DiefBell commented on GitHub (Jul 26, 2019):
Well I'd assume that this would effectively be me overriding the default
UserAgent for my main window?
On Fri, Jul 26, 2019 at 9:03 PM Gregor Biswanger notifications@github.com
wrote:
@GregorBiswanger commented on GitHub (Jul 28, 2019):
Hi @MerrickKing,
I found the following example: https://stackoverflow.com/questions/35672602/how-to-set-electron-useragent
Here is the solution for change the UserAgent with Electron.NET.
In your view you can see the new UserAgent with:
navigator.userAgent;I hope I could help you. Have fun with Electron.NET! Happy coding...