Share via


How to make http requests to your web api hosted in iis from your phone's browser

Question

Thursday, August 8, 2019 12:17 PM

I have been trying to make web api requests to my asp.net core 2.2 web api that is hosted in iis. I can get back results when I use 'example.com:50056/api/Vehicle/GetCarpaint' from my browser. However I get 'This site can't be reached' when I make the same request from my mobile phone's browser. Even when I use the IP address of my the machine where the website is hosted. My pc and phone are both on the same network.

Below, I wrote down my finding to this whole situation.

BROWSER

  • example.com --OK

  • example.com:50056/api/Vehicle/GetCarpaint --OK (getting back data)

  • 192.168.8.X:50056 --Error 400 Bad Request -Invalid Hostname

  • 192.168.8.X:50056/api/Vehicle/GetCarpaint --Error 400 Bad Request -Invalid Hostname

PHONE'S BROWSER

  • 192.168.8.X --OK

  • 192.168.8.X/api/Vehicle/GetCarpaint --Error 404 File or directory not found

  • 192.168.8.X:50056 --Error 400 Bad Request -Invalid Hostname

  • 192.168.8.X:50056/api/Vehicle/GetCarpaint --Error 400 Bad Request -Invalid Hostname

  • example.com --This site can't be reached, drsmashservices.com's server IP address could not be found

  • example.com/api/Vehicle/GetCarpaint --This site can't be reached, example.com's server IP address could not be found

I expected to type the IP address of the site with my port followed by my route however my phone's browser can't seem to find the DNS of my website, additionally, I added an inbound rule with port 50056 and I still can't get it to work, am I missing something?

All replies (5)

Friday, August 9, 2019 6:38 AM âś…Answered

Hi  Mlifonza,

Welcome to the MSDN forum.

As far as I know, if you add the hostname binding for your IIS web site, you could not access your web site by using IP address. It will return the invalid host name.

If you want to let your web application which could be access by Internet, I suggest you could check your domain DNS binding to make sure you have bind the right IP address in your domain DNS.

Best regards,

Sara

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]


Monday, August 12, 2019 11:27 AM

Hi Sara,

Thank you very much for the quick reply. I will research that and then I will give you feedback on how it went.

Warm Regards.


Monday, August 12, 2019 12:08 PM

Hi Sara, 

So I removed the Host name from the bindings and then everything just worked perfectly. Thank you again.

Warm Regards.


Tuesday, August 13, 2019 1:40 AM

Hi Mlifonza,

It's my pleasure and we are so glad to hear that your issue is solved, thanks for your confirmation.

If you have any other issues in the future, please feel free to let us know.

Best regards,

Sara

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]


Friday, April 17, 2020 10:01 AM

Thank you it works for me.