英文:
C# Microsoft.Web.WebView2.WinForms not remember answers to access to geolocation
问题
在加载页面后(使用开源地图),WebView2每次启动时都会要求地理位置权限(我没有清除WebView2的cookie - 但我也没有为cookie设置任何内容 - 这样做有问题吗?)。
如何在 C# 中设置 Microsoft.Web.WebView2.WinForms
(webView2.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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论