首页 > 解决方案 > 如何在 xamarin android 中修复“不允许到 x 的明文 HTTP 流量”

问题描述

我的应用程序 Cleartext HTTP 流量出现问题,不允许发送到 x。

我已经尝试将 android:usesCleartextTraffic="true" 放在我的清单中。但我想将“android:usesCleartextTraffic”标志更改为“false”以防止发送未加密的流量。

如何解决这个问题?

标签: httpxamarin.formshttpsxamarin.androidcleartext

解决方案


你可以用一行代码解决这个问题。在您的 android 项目中的 properties 下打开 AssemblyInfo.cs 并添加以下代码:

[assembly: Application(UsesCleartextTraffic = true)]

推荐阅读