59

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;

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?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Mrk
  • 743
  • 1
  • 6
  • 9

1 Answers1

133

Double click on the Package.appxmanifest file in your project.
Click on the "Capabilities" tab. Add the Private Networks capability to your project.

kain64b
  • 2,258
  • 2
  • 15
  • 27
  • 1
    The name "Private networks" is kind of confusing. I would think that it's something related to intranet. Actually the app basically want to communicate over Internet with our server. Another confusing thing is that exception text doesn't point out which exactly network "capability" (there're bunch of them) need to be added. – Mike Keskinov Mar 10 '17 at 21:34
  • 2
    @MikeKeskinov I had this problem accessing a public server while on VPN. With VPN turned off there was no exception. With VPN on it apparently throws because it goes through the 'private' VPN network. – pauldendulk Dec 14 '17 at 08:16
  • Holy game changer. Thanks a bunch. – Mr. B May 07 '18 at 07:07
  • 1
    Another way of getting to the capabilities tab is to go to Unity Edit>Project Settings>Player>Publishing Settings – Enrique Avina Jan 27 '19 at 17:59