I’m working on UWP app on my laptop. On a previous laptop with a pre-release Windows 10, I was able to get my app to see my web API service on localhost, but on this laptop, no matter what I try, I always get this error using HTTP client:
A connection with the server could not be established
var response = await client.GetAsync(BuildGetRequest()).AsTask(source.Token);
If I point to my published service on Azure, everything works fine. Here’s what I have tried:
Nothing makes any difference.
I have noticed that I’m having a similar problem in Edge, despite allowing Localhost loopback in about:flags
and several other suggestions I found at:
My Web API project runs fine in every browser except Edge, so I’m guessing as Edge is a universal app, the problem is linked. When I debug it in Edge, I get this error:
Can’t connect to the proxy server
If I go to Settings
and switch off the manual proxy server, run it again I get:
Hmm, we can’t reach this page
I notice though that for some reason the Manual Proxy server setting keeps switching back on during subsequent runs.
Could anyone suggest anything else I could try to get my UWP app to see my service on localhost?
1] Find UWP app version via Settings You can first navigate to the Settings icon at the bottom of the window and then click on About. You may also want to navigate to the related links section and then find “About” section to know the version like in case of Windows Defender Security Center app.
UWP apps can make use of Win32 APIs and . NET classes (see API Sets for UWP apps, Dlls for UWP apps, and . NET for UWP apps). The Microsoft development story continues to evolve, and along with initiatives such as WinUI, MSIX, and the Windows App SDK, UWP is a powerful tool for creating client apps.
It's not a bug it's a feature, called network isolation. It was introduced in Windows 8 (where Metro apps were called Windows Runtime apps).
For security reasons, a UWP app that is installed in the standard manner is not allowed to make network calls to the device it is installed on.
More details here and here.
The feature can be disabled in Visual Studio debug settings, also the article How to allow loopback for Windows Runtime apps talks about using the CheckNetIsolation Windows tool to enable loopback access per application:
CheckNetIsolation.exe LoopbackExempt -s CheckNetIsolation.exe LoopbackExempt –a –p=S-1-15-2-4125766819-3228448775-2449327860-2490758337-1264241865-3581724871-2122349299
There are also GUI tools such as Enable Loopback Utility and Loopback Exemption Manager which make this task easier:
It might be in the future with the project reunion .
https://github.com/microsoft/ProjectReunion/issues/113
Give your demand some emphasis in this ticket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With