0

I have a C# webserver running on my PC, i can do request to it from a browser and a Console Application (both on the same PC, the same of webserver) and I can access it using Android Emulator too.

Then I have an Android app in C# which should make a simple request (two methods):

using (var ws = new WebClient())
            {
                try
                {
                    Uri uri = new 
                    Uri("http://192.168.137.1:4100/1/2/3/4/5");
                    ws.DownloadStringAsync(uri);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            using (var cl = new HttpClient())
            {
                HttpResponseMessage res = await cl.GetAsync("http://192.168.137.1:4100/1/2/3/4/5");
                Console.WriteLine(res.ToString());
            }

But i can't access from it. I'm using Android 6.0.1 (API 23).
Some months ago this app was working, so I don't know if it a network problem or a device(smartphone) problem.

Can some one help me?

Riccardo Raffini
  • 366
  • 7
  • 20
  • Where is the Android app executed? On a physical smartphone? Or an emulator on your PC? – Alex Nov 13 '18 at 16:17
  • 1
    If i run it on the emulator works, but i need to run it on a physical smartphone. – Riccardo Raffini Nov 13 '18 at 16:19
  • So you run the server-app on your pc on port 4100 and the app on your physical device? In this case this sounds like a networking problem. Are both devices (pc and smartphone) in the same subnet, is port 4100 on your pc listening on all incoming ip-ranges, is your firewall configured to allow incoming tcp traffic on port 4100, do you have a proxy configured, ...? – Alex Nov 13 '18 at 16:23
  • 1
    They are in the same network (I'm using wi-fi). I've set a new incoming rule for port 4100 and I've disabled PC Firewall just in case. And I'm not using a proxy. – Riccardo Raffini Nov 13 '18 at 16:36
  • Can you access the url from a browser on your smartphone? – Alex Nov 13 '18 at 16:57
  • Nope. Can't access. By the way thanks for helping. – Riccardo Raffini Nov 13 '18 at 17:05
  • So there is no problem with the app itself. Try to access the url from another device in your wlan, but I think this won't work, too. I think your IISExpress is not listening correctly. – Alex Nov 13 '18 at 17:25
  • 1
    well, as you said it isn't working with an other device. If I understand what you said, i tried to run issexpress /trace:true on cmd that starts a "site" and calling it with localhost: 8080/ returns error 500.19-internal server error – Riccardo Raffini Nov 13 '18 at 18:06
  • Maybe this link helps you: https://stackoverflow.com/questions/3313616/how-to-enable-external-request-in-iis-express – Alex Nov 13 '18 at 18:50
  • I'll try. Thanks for your help. – Riccardo Raffini Nov 13 '18 at 20:02

0 Answers0