Android device connection refused in WebClient download request on localhost PC

Raymond Larkin 1 Reputation point
2022-06-11T00:11:18.5+00:00

A VisualStudio 2019 project running on Windows 10 Home was taken from a tutorial that actually targeted Phone 8. It is a 'Book Store' app using data stored in an XML file which is loaded into the local host web page built with Asp.Net Core Web app. My Windows machine is wired to the router and the Android phone is USB tethered to the PC. The Android manifest has permissions for Internet and Network_State.

There is a call in the Mobile App using Xamarin.Forms that uses WebClient to down load the catalog from the server. The down load call has an event handler that is built to respond when the down load is complete.

With the firewall enabled the request times out. With the firewall off the request returns immediately with exception ConnectionFailure: Connection refused. It doesn't help to run VS as administrator.

The mobile app is using the Ip address of the PC and a number of ports have been tried yielding the same response.

As a note, I had to change the Api controller from using HttpResponseMessage to IActionResult because I believe target platforms may be different or changes in .Net versions pushed the issue.
As another note, I previously built a Xamarin.Android app that I could explore all the shared drives on my PC with. I'm not sure that has any bearing on this problem, but, I could access the PC through the wifi using the same Ip address of the PC.

Help in finding direction to resolve the issue would be appreciated.

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,353 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,931 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.