How can I access my localhost on my computer from my Android device? - asp.net-mvc

I have a web application written in ASP.NET MVC 5. I simply can open it from the browser with this localhost:14920 in my computer, but I want to access the same application from my Android device's browser while my laptop and Android device are in the same network. I don't know how to access it from Android.
Note: when I type 127.0.0.1 in the Android browser I can access the IIS server, but when I type 127.0.0.1:14920 it prints Bad Request - Invalid Hostname. How can I fix this issue?

You can configure IISExpress for remote access
http://www.ryadel.com/en/iis-express-allow-external-requests-remote-clients-devices/
or just change the hosting to IIS as the earlier commenter mentioned.

Try with replacing 127.0.0.1 with your IPv4 address.

I have used ngrok in the past, when needing to hit my development machine, or have someone else hit it. It is a very useful tool and very simple to install.
Once you download it, it's just a simple command line:
https://ngrok.com/docs#expose
ngrok http 80
(That is for traffic on port 80) Since your port above looks different it would be:
ngrok http 14920
That will give a URL that you can hit or any machine or device.

Related

The question is about localhost, Swift URL, NetBeans and Xampp

everyone, I have a question to ask about "localhost"
I am a newbie and use NetBeans and Xampp as DATABASE to connect with Swift.
I use "http://localhost/" as my URL on the simulator of Mac, which works fine.
But when I change to my physical device, it has an error " can not connect to the server", how can I solve this problem?
And another question, if one day I publish the APP, what URL should I use? Is it still "http://localhost/" or anything else? I am really confused, can someone give me some advice? I would really appreciate!
localhost is 127.0.0.1 address, used only in current machine.
When you using simulator, simulator run in same machine with server, it will success access 127.0.0.1 address.
If you using real device, please find your server ip with command ifconfig and use that in App.
Hope to help you.
As was written in the comments, http://localhost/ only works on the current device (similar if you are using http://127.0.0.1). The simulator is running on your Mac, so it will work.
Since the physical device is not on your Mac, it will not work. So, for testing, you might want to set up a test server on your computer or on another machine. Then, you would replace the URL with the IP address or hostname of the server. For production, you would need to set up a server or find a hosting service. Then, you would use the URL for whatever server you go with in your app instead of http://localhost/.

Cannot load site on localhost with iOS devices on BrowserStack Automate

I'm hosting a .NET Core HTTP application on localhost using Kestrel on an available port for some browser-based UI tests, but when trying to access it using real iOS devices with BrowserStack Automate with BrowserStackLocal.exe, Safari consistently refuses load the page.
I've tried various parts of the IP ranges documented here, but none have been successful. Desktop browsers (Chrome, IE, Edge and Firefox on Windows, Safari on macOS Mojave) and real Android devices work as expected.
I've also tried using the local IP address of the machine and the fully-qualified domain name (FQDN) as described here, but neither work portably as Windows Firewall blocks the connections even through BrowserStack Automate can resolve the address.
Port 80 is not a viable solution as developers' machines will have IIS running on their machines using that port, so it is not available for other purposes.
Given the following constraints, what are the workable solutions?
Hosted on HTTP.
Runs without admin privileges (i.e. no reconfiguring the firewall or using privileged port numbers <1024).
At least two possible port numbers to use so that if one is in use there's at least one alternate to try.
No additional manual setup required to run the tests (should just be the command dotnet test).
On the iOS devices, try resolving http://bs-local.com:5000 instead of http://localhost:5000.
You can access the site using http://bs-local.com:5000, But make sure to disable the host check for webpack using disableHostCheck: true in configuration.
For angular cli users, to disable to the host check you need to use --disable-host-check like ng serve --port 4200 --disable-host-check
This is from BrowserStack's support:
a) On Safari
Previously, accessing local websites with 'localhost/127.0.0.1' in the URL was not supported on iOS devices running iOS versions 10 and above.
However, to make sure that your website loads with 'localhost' in the URL, we now modify the URL to http://bs-local.com on these devices. This helps in loading your website in an expected manner. The same is mentioned here.
In the screenshot you've shared, you can see the redirection to bs-local.com as well.
It seems that your localhost website is configured to be accessible only via specific hostnames such as 'localhost'. Thus, you face the reported error.
To be able to test your localhost website via Safari on iOS devices, I would recommend configuring your localhost website to be accessible via the private IP address of your local machine.
Once done, you can access your localhost website as http://<private_IP_address:port> and this should work.
I would also encourage reading through this guide to understand how you could achieve the above: https://www.notion.so/Testing-localhost-on-iOS-devices-1ceb5e274cee46d7ac538b71304919b4
b) On Chrome
Due to restrictions imposed by Safari, testing localhost websites on Chrome is not supported by default on iOS devices.
The problem arises with the usage of the domain 'localhost'. We are actively trying to find alternatives for this behavior as well.
However, in the meantime, you can access your localhost website via the private IP address as mentioned above via Chrome browser on iOS devices as well.
Once you make the necessary changes to your configuration to allow your localhost website to be accessible via the private IP address, you can test your localhost website via Chrome on iOS as well.
Feel free to reach out should you need any further assistance!
Note: The private IP address is not the same as 127.0.0.1. You can use this article to identify the private IP address of your machine.
Regards,
Reehan
BrowserStack Support
Did you try changing the 'localhost' with the IP address of the machine (where the web is hosted)?
For instance - If the IP for the machine on which application/webpage is hosted is 22.22.22.22, then change http://localhost:3000/index.html to http://22.22.22.22:3000/index.html in your test
They have mentioned the same here - https://www.browserstack.com/question/663
If you are using Angular CLI then please run command
ng serve --host 0.0.0.0 --port xxxx
This will make sure that you would be able to access application using your IP and port specified. Once done you should be able to access your application using browser stack iPhone device browsers using IP and port rather than localhost.

why I am not able to access rails localhost on my mobile or other computer

I am trying to access my localhost of rails running project on my mobile device.
This is how I am trying.
http://ip:3000
But it says the webpage is not available.
I tried with another port as well and It doesn't work even there?
What's wrong here? I use to check earlier this way.
Please guide
Try running this code below to your server:
rails s -b 0.0.0.0
This worked for me!
Just give:
ip = your phone's ip address
(Check it in connection information if you are running this on Ubuntu)
ip:3000/your_page if you do not have mapped your root to some page.
Else ip:3000 will work if you have mapped root to some page.
Try it in Chrome and see as it doesn't need any http or https it automatically selects the required one.
Here is how I did it
Put both your computer and phone on the same wifi network
rails s -b 0.0.0.0
routerlogin.net (or however you access your router it will say on the back of router)
get attached devices to the router. Note your computers ip. Mine was 10.0.0.20
on phone go to 10.0.0.20:3000 (but use the ip for your computer from step 4)

testing mobile apps at home (IIS hosted)

I am not sure what to look for with the current problem and I appreciate your suggestions.
Basically, all I want to do is locally host a web application on IIS and access it from my mobile browser.
My web application is hosted on the local IIS and works fine on the main machine. I can use my computer name, internal ip or external ip instead of localhost to connect to the app from the main computer. But when I go to another computer (which I can see and exchange files with) connected to the same network I cannot access the web application on the main machine. I tried ip and machine name.
At work, we are connected to a Domain and I tried the same thing with the work computer. When I write my computer name or it's ip, I can access hosted app from another computer.
So the question is, do I have to have a domain for this capability and if so, Is it possible to create a local domain at a home network? What do I need to search for to get this working? Is WAMP a must?
Apparently opening the outbound/inbound port 80 from windows firewall is enough

Problem Publishing Silverlight Application LocalHost

I am trying to publish my SilverLight application to the web and I keep getting "An error occurred while trying to make a request to URI "http://localhost:2898....".
I've changed the ServiceReferences.ClientConfig to point to the web address but the app still keeps on trying to connect to localhost.
I've opened the application in FireFox and took a look at the firebug log and it says: -
clientaccesspolicy.xml 404 Not Found localhost:2898
crossdomain.xml 404 Not Found localhost:2898.
The silverlight app is accessing the web service in the same domain, I just don't know why it is still trying to connect to localhost.
Any help appreciated.
Steve
Two things come to mind, but check your "c:\windows\system32\drivers\etc\hosts" file and make sure ure local computer name or ip isnt mapped to localhost or the network machine isnt mapped to localhost for whatever strange reason.
Is the Silverlight app And WCF Service hosted on your localmachine, or are you accessing a server on your local network?
Just open the hosts file (C:\windows\system32\drivers\etc) and uncomment the following line (remove # from the beginning of the line): 127.0.0.1 localhost
Then save it, it should work.

Resources