通用Windows项目-HttpClient异常 [英] Universal Windows project - HttpClient exception
问题描述
我正在尝试使用HttpClient在Universal Windows项目(在Windows 10通用应用程序中)中实现REST客户端,但是以下行:
I'm trying to implement REST client in Universal Windows project (in Windows 10 universal app) using HttpClient, but the following line:
var response = _client.GetAsync(address).Result;
抛出带有以下消息的AggregateException:
throws an AggregateException with the following message:
访问被拒绝.需要具备网络功能才能访问此功能网络资源
Access denied. A network capability is required to access this network resource
更令人惊讶的是,请求不是事件发送到服务器.我该如何解决这个问题?
More surprisingly, the request isn't event sent to server. How can I solve this problem?
推荐答案
双击项目中的Package.appxmanifest文件.
点击功能"标签.将专用网络功能添加到您的项目中.
Double click on the Package.appxmanifest file in your project.
Click on the "Capabilities" tab. Add the Private Networks capability to your project.
这篇关于通用Windows项目-HttpClient异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!