ChatGPT解决这个技术问题 Extra ChatGPT

Viewing localhost website from mobile device

I have an ASP.Net website hosted on my Win8's localhost, the site seems to be running as expected on the desktop, but now i also want to test the site website on mobile device to check how it renders

Is there anyway i can access the website from my mobile device

My Mobile Device and Desktop Machine are connected to the same Network via Router.

Here are the details of my machine and router.

Machine has Win8 Pro Installed running IIS 8.0.9200.16384 Router is TP-Link Basic 150Mbps. Device is Karbonn A15, Android - 4.0.4 (ICS)

Can anyone tell me how can i connect my mobile device to localhost website.

Let say that the desktop have inside network ip: 147.102.1.1, then add to the IIS bindings for that ip, and call it from the mobile browser phone.
If you don't mind can you please provide step by step instruction, i am total newbie in networking, My machine IP is 192.168.0.102

J
Joffrey Kern

To view localhost website from mobile device you have to follow thoses steps :

In your computer, you have to retrieve your IP address (Run > cmd > ipconfig)

If your localhost use a specific port (like localhost:12345 ), you have to open the port on your computer (Control Panel > System and Security > Firewall > Advanced settings and add Inbound rule)

Finally, you can access to your website from mobile device by navigate to : http://192.168.X.X:12345/

Hope it helps


You're welcome :) I did it last week with a Windows Phone emulator ;)
Hi @Joffrey Kern, now i have Windows 7 installed and rest configuration being same, i am unable to connect to my website using mobile can you please help me with that
could you tell us something more about the steps to add the inbound rule?
works great, thanks. for xampp users, simply edit the httpd-xampp.conf file by commenting out the last 4 lines begining with ""
I thought we have to establish some live routine and live ip. OMG, it was tricky. If you are on same wifi this is magic. Thank you
P
Piotrek

One of the easiest way to remotely access ASP.net local website, without messing with adding new rules to firewall, is to use this Visual Studio extension:

Conveyor by Keyoti (Visual Studio extension)

Just install it. Every time when you run your project, it will show you URL which can be used for remote access. No other configruration required.

https://i.stack.imgur.com/38Omd.png


Really nice tool:)
What's the advantage of using Conveyor over just simply adding a rule to the firewall? Setting up Conveyer requires you to add a rule to the firewall anyway.
This response should be the the real solution of this topic. This enxtension is working on VS 2019, i use it to debug my API deployed on IIS Express to test if my Xamarin application trigger fonctions correctly. Thanx a lot !
Thanks allot, really it's a great tool.
does it work when running from console: dotnet run ?
k
kevin onofre

Use Conveyor by Keyoti (extensión de Visual Studio). Extension visual studio


n
neave

Another option is http://localtunnel.me/ if you're running NodeJS

npm install -g localtunnel

Start a webserver on any local port such as 8080, and create a tunnel to that port:

lt -p 8080

which will return a public URL for your localhost at randomname.localtunnel.me. You can request your own subdomain if it's available:

lt -p 8080 -s myname

which will return myname.localtunnel.me


This is a great tool, but I get a lot of timeouts using it.
Excellent answer! the only one worked for me on Windows 10
B
Buurman

Try this https://ngrok.com/docs#expose

Just run ngrok 3000 , 3000 is the port number you want to expose to the internet. You can insert the port number which you want to expose, for rails its 3000. This will tunnel your localhost to the internet and you will be able to view your local host from anywhere


Usually, if both devices are on the local network, you can also access the site by connecting to http://<local ip>:<portnumber>. Could you also explain what url/ipaddress the user should access to reach his site and whether or not a firewall might be an issue with ngrok?
S
Sreilus

You can solve the problem by downloading the 'conveyor' library from extensions and update in Visual Studio.

You can access it from other devices.

Open Visual Studio

Tools > Extensions and Updates

Online > Visual Studio Marketplace

Search 'Conveyor'

Download and install this extension

When you launch the API, you can access it from other devices. This plugin creates a link from your own ip address.

Example: https://youripadress:5000/api/values


A
Amin

Here is how I managed to make it work for VS 2015 on Windows 10 pro using following steps. It works for both http and https websites. (below example assumes your ip address is 192.168.1.15 and your port number is 12345)

Open project config file at /{project folder}/.vs/config/applicationhost.config and add a new binding address inside section as shown below (a binding for localhost is already there, just copy/paste the same line and replace localhost with your IP address)

    <bindings>     
       <binding protocol="http" bindingInformation="*:12345:localhost" />          
       <binding protocol="http" bindingInformation="*:12345:192.168.1.15" />  
    </bindings>

Open Command Prompt window as administrator and run the following command.

    netsh http add urlacl url=http://192.168.1.15:12345/ user=everyone

Open "Windows Defender Firewall and Advanced Security" select "Inbound Rules" click "New Rule..." select "Port" then add TCP port 12345 and click next to finish the process. Right-click on Visual Studio shortcut and select "Run as administrator", then open your project and press Ctrl+F5 to open the website. Inside browser address bar, replace localhost with 192.168.1.15 and hit enter to reload your website with the new address. Now you should also be able to access the website from your mobile browser using the same address as long as it's connected to the same wifi.

If it doesn't work, make sure visual studio is run as administrator. (step 4)


A
Ali

First of all open applicationhost.config file in visual studio. address>>C:\Users\Your User Name\Documents\IISExpress\config\applicationhost.config

Then find this codes:

<site name="Your Site_Name" id="24">
        <application path="/" applicationPool="Clr4IntegratedAppPool"
        <virtualDirectory path="/" physicalPath="C:\Users\Your User         Name\Documents\Visual Studio 2013\Projects\Your Site Name" />
        </application>
         <bindings>      
           <binding protocol="http" bindingInformation="*:Port_Number:*" />
         </bindings>
   </site>

*)Port_Number:While your site running in IIS express on your computer, port number will visible in address bar of your browser like this: localhost:port_number/... When edit this file save it.

In the Second step you must run cmd as administrator and type this code: netsh http add urlacl url=http://*:port_Number/ user=everyone and press enter

In Third step you must Enable port on firewall

Go to the “Control Panel\System and Security\Windows Firewall”

Click “Advanced settings”

Select “Inbound Rules”

Click on “New Rule …” button

Select “Port”, click “Next”

Fill your IIS Express listening port number, click “Next”

Select “Allow the connection”, click “Next”

Check where you would like allow connection to IIS Express (Domain,Private, Public), click “Next”

Fill rule name (e.g “IIS Express), click “Finish”

I hopeful this answer be useful for you

Update for Visual Studio 2015 in this link: https://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer


A
A Programmer

In additional you should disable your antivirus or manage it to open 80 port on your system.


佚名

Know your host ip address on your lan Open cmd and type ipconfig and the if xampp the default listen port would be 80 Then for instance if 10.0.0.5 is your host ip address Type 10.0.0.5:80 from your mobile's web browser Make sure that both are connected to the same LAN However the default port that webaddress tries is 80.


A
Amir Dora.

A very simple way.

Go to CMD and type the following without '$' and choose a name as your HotspotName and a password as your HotspotPassword. $ netsh wlan set hostednetwork mode=allow ssid=HotspotName key=HotspotPassword $ netsh wlan start hostednetwork Connect your phone to the WiFi and explore its network info, get Gateway address it's kinda like IP address. Enter the Gateway address into Chrome URL bar and you're good