Solution 1 :
non-conforming client (such as in a mobile app, or just a shell script invoking curl), can and usually will completely ignore CORS. My best guess is CORS is not the problem here. So you have to check that your app can connect to the API. just launch browser on your phone and copy paste the API Ednpoint URI and check if the get request was success.
Problem :
I am having trouble now connecting to my simple API from my Android application project. I have my web application running on localhost:5001, I am able to get responses using POSTMAN and via URL in browsers. But when I run my android application in debug mode I cannot get any response from the api call. I simply use a bog-standard button on the pre-built app template. I see the GET request being executed but I get no response and no error/break in debug. I have changed the localhost:5001 to 192.168.x.xxx:5001 (myip), using localhost gave a connection refused error. I have also added rule in firewall to allow TCP connections to all local ports.
Any help would be appreciated
Kind regards
simple API call code on button click
error using my ip, just loads forever
PUBLISHED EXE localhost server running
I have also tried disabling the router firewall, and using port forwarding for HTTPS Server to my IP address
Comments
Comment posted by Mofid.Moghimi
You need to handle Cors Origin on your web api application
Comment posted by 192.168.x.xxx:5001
Thank you for the quick response, I added cors via NuGet PowerShell, and added app.UseCors() and added [EnableCors(origins: “
Comment posted by localhost:5001/api/Data?driverCode=1LINK
Hi thank you for reply, i hvae posted the error i recove when just using the emulator browser with URL
Comment posted by Paul
that works fine in postman, if i change the localhost to my IP address in the mobile browser then the browser just loads forever
Comment posted by Paul
I also cannot access from my physical phone browser same results as emulator 🙁
Comment posted by Paul
And I also do believe this could be network related, is there anymore configuration I could check? Could it be relates to my ISP or router? I use plusnet for example
Comment posted by Paul
One more thing im reading, does my server need to be uploaded to a hosting site for this to work? im currently running the server on my PC via published debug exe (pictured), im also connected to the wifi via an internet booster as my router is to far from my room?