【问题标题】:Cannot load http links in webview xamarin forms无法在 webview xamarin 表单中加载 http 链接
【发布时间】:2022-07-27 17:50:00
【问题描述】:

我正在创建一个 webview,它将加载我的 url 链接,例如“http://test.rf.gd/index”,但是当我尝试在 webview xamarin 中加载它时它没有加载它说 net::ERR_CLEARTEXT_NOT_PERMITTED

我创建了一个新的 Cookie webview,但它也不起作用

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using System.Net;
using System.Web;
using Xamarin.Forms;

namespace OMA.WebCookie
{
    public class CookieWebView : WebView
    {
        public static readonly BindableProperty UrlProperty = BindableProperty.Create(propertyName: "Url", returnType: typeof(string), declaringType: typeof(CookieWebView), defaultValue: default(string));

        public string Url
        {
            get { return (string)GetValue(UrlProperty); }
            set { SetValue(UrlProperty, value); }
        }

        public CookieCollection Cookies
        { get; protected set; }
    }

    public enum CookieNavigationMode
    {
        Back,
        Forward,
        New,
        Refresh,
        Reset
    }
}

如何在 xamarin webview 中加载 http 链接?

【问题讨论】:

    标签: c# webview


    【解决方案1】:

    我不知道你是否解决了问题,但你需要在 AndroidManifest.xml 中添加这个配置,恰好在 application 标签中

    android:usesCleartextTraffic="true"
    

    这将允许您的android应用程序加载http链接,在iOS上允许它是另一回事,您可以找到解决方案here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-10
      • 2018-12-29
      • 1970-01-01
      • 1970-01-01
      • 2015-12-17
      • 2019-07-21
      相关资源
      最近更新 更多