Viewing localhost website from mobile device

后端 未结 11 1700
南方客
南方客 2020-11-27 11:23

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 t

相关标签:
11条回答
  • 2020-11-27 11:44

    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

    0 讨论(0)
  • 2020-11-27 11:47

    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)

    1. Open project config file at /{project folder}/.vs/config/applicationhost.config and add a new binding address inside <binding> 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>
    
    1. Open Command Prompt window as administrator and run the following command.
        netsh http add urlacl url=http://192.168.1.15:12345/ user=everyone
    
    1. 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.

    2. Right-click on Visual Studio shortcut and select "Run as administrator", then open your project and press Ctrl+F5 to open the website.

    3. 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)

    0 讨论(0)
  • 2020-11-27 11:50

    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

    0 讨论(0)
  • 2020-11-27 11:55

    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

    0 讨论(0)
  • 2020-11-27 11:56

    A very simple way.

    1. 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=HotspotName key=HotspotPassword

      $ netsh wlan start hostednetwork

    2. Connect your phone to the WiFi and explore its network info, get Gateway address it's kinda like IP address.

    3. Enter the Gateway address into Chrome URL bar and you're good

    0 讨论(0)
  • 2020-11-27 12:01

    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

    0 讨论(0)
提交回复
热议问题