【问题标题】:Xamarin Forms UWP Project cant connect to external service (localhost working)Xamarin Forms UWP 项目无法连接到外部服务(本地主机工作)
【发布时间】:2017-02-03 10:25:22
【问题描述】:

我正在测试我的应用程序,它使用的是 RESTful 服务。到现在为止还挺好。我已将我的服务部署到 aszure 并且一切正常。现在的问题是,我的 UWP-Application 拒绝连接到该服务。

我正在使用 HTTPClient

Client = new HttpClient();
Client.MaxResponseContentBufferSize = 256000;
Client.Timeout = TimeSpan.FromSeconds(5);

var response = Client.GetAsync(uri).Result;

Client.GetAsync 向我抛出异常。

我已在 Package.appxmanifest(Internet 和专用网络)中设置功能

例外:

Count = error CS0103: The name 'InnerExceptionCount' does not exist in the current context

内部异常:

{"Der Text zu diesem Fehlercode wurde nicht gefunden.\r\n\r\nDie Serververbindung konnte nicht hergestellt werden.\r\n"}

InnecException 是德语,意思是“找不到此错误代码的文本。无法连接到服务器。”

在使用 localhost 以外的其他服务时遇到此异常真的很奇怪,如果我使用 localhost,一切正常。你有什么建议吗?

屏幕截图包.appxmanifest (UWP):

【问题讨论】:

  • 我也有同样的问题,你找到解决办法了吗? (gleiche Fehlermeldung ;))

标签: c# rest uwp xamarin.forms


【解决方案1】:

执行异步调用的方法并不正确

var response = await Client.GetAsync(uri);

我假设服务正在返回对您“获取”的网址的响应

【讨论】:

  • .Result 也在等待它
猜你喜欢
  • 2020-12-03
  • 1970-01-01
  • 2014-03-23
  • 2019-09-21
  • 1970-01-01
  • 2017-04-15
  • 2018-11-03
  • 1970-01-01
  • 2016-02-19
相关资源
最近更新 更多