发布于 2025-01-29 09:41:06 字数 1097 浏览 4 评论 0 原文

使用vs 17.3预览1,.net Maui Blazor,我无法在Android中获得HTTPCLCLIENT或WEBREQUEST。我已经尝试了所有Android选项项目设置(空白,托管,Android,Legacy),也是TLS空白和1.2。我已经尝试了各种解决方法:

  1. xamarin.android.net.androidMessageHandler client Handler //用于消息处理程序

  2. servicepointManager.CheckCertificateReateRevecationListlist = false; > servicepointManager.ServerCertificateValidationCallback =委托{return true; };

我尝试了所有这些不同的组合,并在Android设备上形成了Android模拟器。

我来的壁橱与WebRequest一起: 状态:Unknownerror 消息:无法建立SSL连接,请参见内部异常。

有人设法打了HTTPS吗?有什么想法或建议吗?
提前致谢, 富有的


WebRequest request = WebRequest.Create("https://fonts.googleapis.com"); // any https site
request.Method = "POST";                                      
string postData = win;  
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();

Using VS 17.3 Preview 1, .Net Maui Blazor, I can't get httpclient or webrequest to work at all in Android. I've tried all the android option project settings (blank, managed, Android, legacy), also tls blank and 1.2 . I've tried various workarounds:

  1. Xamarin.Android.Net.AndroidMessageHandler clientHandler //for message handler

  2. ServicePointManager.CheckCertificateRevocationList = false;
    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

I've tried all these different combinations form the Android emulator and also on an android device.

The closet I've come is with webrequest:
status: UnknownError
message: The SSL connection could not be established, see inner exception.

Has anyone managed to make an https call? Any ideas or suggestions?
Thanks in advance,
Rich


WebRequest request = WebRequest.Create("https://fonts.googleapis.com"); // any https site
request.Method = "POST";                                      
string postData = win;  
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ˉ厌 2025-02-05 09:41:06

是的,我已经能够无问题地使它起作用。这应该有帮助。

我仍然无法让Maui Android使用ServiceModel连接。该应用程序将在Windows和iOS上编译和运行,而不会发生任何事件,但不要使用Android。

Yes, I have been able to get it to work without issues. This should help.
.Net Maui Blazor - Does HttpClient or WebRequest work at all?

I still cannot get Maui Android to work with ServiceModel connection. The app will compile and run on windows and ios without incident but not Android.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文