Universal Windows project - HttpClient exception

13,519

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

Share:
13,519
Mrk
Author by

Mrk

Updated on June 06, 2022

Comments

  • Mrk
    Mrk almost 2 years

    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?

  • Mike Keskinov
    Mike Keskinov about 7 years
    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.
  • Jakub Bielan
    Jakub Bielan over 6 years
    @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.
  • Mr. B
    Mr. B almost 6 years
    Holy game changer. Thanks a bunch.
  • Ricky Avina
    Ricky Avina over 5 years
    Another way of getting to the capabilities tab is to go to Unity Edit>Project Settings>Player>Publishing Settings