C# Microsoft.Web.WebView2.WinForms 无法记住对地理位置访问的答案。

huangapple go评论69阅读模式
英文:

C# Microsoft.Web.WebView2.WinForms not remember answers to access to geolocation

问题

在加载页面后(使用开源地图),WebView2每次启动时都会要求地理位置权限(我没有清除WebView2的cookie - 但我也没有为cookie设置任何内容 - 这样做有问题吗?)。

如何在 C# 中设置 Microsoft.Web.WebView2.WinFormswebView2.CoreWebView2)来记住一次性用户答复或默认设置访问地理位置权限,就像在 Edge 浏览器中一样?

英文:

After loading the page (with the openstreet map), WebView2 asks for geolocation permission every time it is started (I do not clear WebView2 cookies - but I don't set anything either for cookies - is that wrong?).

How to set C# Microsoft.Web.WebView2.WinForms (webView2.CoreWebView2? ) to remember a one-time user answer or set permission to access geolocation by default, as for example in the Edge browser?

答案1

得分: 2

你可以使用实验性的 SetPermissionState API 来在配置文件上实现这一点 - 它是 1.0.1671-prerelease 包的一部分,并应该在下一个发布包中提供。

你还可以处理 PermissionRequested 事件,以拦截权限请求并从 事件参数 args 中设置权限状态。

英文:

You can use the experimental SetPermissionState API on the profile to accomplish this - it's part of the 1.0.1671-prerelease package and should be in the next release package.

You can also handle the PermissionRequested event to intercept permission requests and set permission state from the event args.

huangapple
  • 本文由 发表于 2023年3月4日 03:23:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75631118.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定