首页 > 解决方案 > 在 Xamarin.MAC 上使用 WebView 时出错

问题描述

当我尝试登录我的谷歌帐户时,我收到此错误。我在 Xamarin.MacOS 上使用 WebView

错误信息

<controls:WebViewer x:Name="webView" Source="{Binding Url}" VerticalOptions="FillAndExpand"
                                Navigated="Web_OnNavigated"
                                Navigating="Web_OnNavigating" HorizontalOptions="FillAndExpand" />

我如何添加 WebViewer

public class WebViewer : WebView
{
    public static BindableProperty GetCookiesProperty =
        BindableProperty.Create(nameof(GetCookies), typeof(Func<string, CookieContainer>), typeof(CookieContainer),
            null, BindingMode.OneWayToSource);

    public static BindableProperty EvaluateJavascriptProperty =
        BindableProperty.Create(nameof(EvaluateJavascript), typeof(Func<string, Task<string>>), typeof(WebViewer),
            null, BindingMode.OneWayToSource);

    public Func<string, CookieContainer> GetCookies
    {
        get => (Func<string, CookieContainer>) GetValue(GetCookiesProperty);
        set => SetValue(GetCookiesProperty, value);
    }

    public Func<string, Task<string>> EvaluateJavascript
    {
        get => (Func<string, Task<string>>) GetValue(EvaluateJavascriptProperty);
        set => SetValue(EvaluateJavascriptProperty, value);
    }
}

有我对 WebViewer 的定义

这是我用来登录的网址

Url = "https://accounts.google.com/ServiceLogin/signinchooser?service=youtube&hl=en&passive=true&ltmpl=music&continue=https://www.youtube.com/signin?app=desktop&hl=en&feature=__FEATURE__&action_handle_signin=true&next=https%3A%2F%2Fmusic.youtube.com%2F&uilel=3&flowName=GlifWebSignIn&flowEntry=ServiceLogin";

Mb,您知道 webView 的任何更好的类似物在 MacOS 上可以使用什么?URL 是有效的。我在 Windows 上与 CefSharp 有相同的项目,它没有任何问题。我正在尝试在我的 MACOS 桌面应用程序上登录表单,但是当我尝试登录时它失败了。我没有使用 Oauth,用户是使用他的凭据登录,我得到 cookie,当我使用 youtube 的 web api 时(非官方)

标签: c#.netxamarin

解决方案


推荐阅读