如何在 cefsharp 中授予地理定位权限

发布于 2025-01-16 11:26:34 字数 746 浏览 1 评论 0原文

我最近创建了基于 cefsharp 的项目,我想授予站点地理定位权限,但不知道为什么我的代码不起作用。我收到这个错误:

CefSharp.DevTools.DevToolsClientException:'DevTools 客户端错误 :不支持浏览器上下文管理。' .

我在这个主题上没有找到任何东西。

代码:

public async void init(){
            await webBrowser.WaitForInitialLoadAsync();

            using (var devToolsClient = webBrowser.GetDevToolsClient())
            {
                CefSharp.DevTools.Browser.PermissionDescriptor perm = new CefSharp.DevTools.Browser.PermissionDescriptor();
                perm.Name = "geolocation";
                await devToolsClient.Browser.SetPermissionAsync(perm, CefSharp.DevTools.Browser.PermissionSetting.Granted ,"https://www.test.com/") ;
            }
        } 

I have recently created project based on cefsharp and I want to give permission for geolocation to a site, but idk why my code doesn't work. I got this error :

CefSharp.DevTools.DevToolsClientException : 'DevTools Client Error
:Browser context management is not supported.' .

I have don't find anything at this subject.

The code :

public async void init(){
            await webBrowser.WaitForInitialLoadAsync();

            using (var devToolsClient = webBrowser.GetDevToolsClient())
            {
                CefSharp.DevTools.Browser.PermissionDescriptor perm = new CefSharp.DevTools.Browser.PermissionDescriptor();
                perm.Name = "geolocation";
                await devToolsClient.Browser.SetPermissionAsync(perm, CefSharp.DevTools.Browser.PermissionSetting.Granted ,"https://www.test.com/") ;
            }
        } 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文