从移动设备查看localhost网站

问题描述 投票:60回答:8

我有一个ASP.Net网站托管在我的Win8's localhost上,该网站似乎在预期的桌面上运行,但现在我也想测试移动设备上的网站网站以检查它是如何呈现的

无论如何我可以从我的移动设备访问该网站

我的移动设备和台式机通过路由器连接到同一网络。

以下是我的机器和路由器的详细信息。

  1. 机器安装了Win8 Pro,运行IIS 8.0.9200.16384
  2. 路由器是TP-Link Basic 150Mbps。
  3. 设备是Karbonn A15,Android - 4.0.4(ICS)

任何人都可以告诉我如何将我的移动设备连接到localhost网站。

asp.net windows-8 localhost
8个回答
97
投票

要从移动设备查看localhost网站,您必须按照以下步骤操作:

  • 在您的计算机中,您必须检索您的IP地址(运行> cmd> ipconfig)
  • 如果您的localhost使用特定端口(如localhost:12345),则必须打开计算机上的端口(控制面板>系统和安全>防火墙>高级设置并添加入站规则)
  • 最后,您可以通过以下方式从移动设备访问您的网站:http://192.168.X.X:12345/

希望能帮助到你


12
投票

远程访问ASP.net本地网站的一种最简单的方法是使用此Visual Studio扩展,而不必为防火墙添加新规则。

Conveyor by Keyoti (Visual Studio extension)

只需安装它。每次运行项目时,它都会显示可用于远程访问的URL。无需其他配置。

enter image description here


4
投票

试试这个https://ngrok.com/docs#expose

只需运行ngrok 30003000就是您想要暴露给互联网的端口号。您可以插入要显示的端口号,对于rails它是3000.这会将您的localhost隧道传输到Internet,您可以从任何地方查看本地主机


4
投票

如果您正在运行NodeJS,另一个选择是http://localtunnel.me/

npm install -g localtunnel

在任何本地端口(如8080)上启动Web服务器,并创建到该端口的隧道:

lt -p 8080

它将在randomname.localtunnel.me中返回localhost的公共URL。您可以申请自己的子域名(如果可用):

lt -p 8080 -s myname

这将返回myname.localtunnel.me


1
投票

首先在visual studio中打开applicationhost.config文件。地址>> C:\Users\Your User Name\Documents\IISExpress\config\applicationhost.config

然后找到这个代码:

<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:当您的站点在您的计算机上运行IIS Express时,端口号将在浏览器的地址栏中显示如下:localhost:port_number / ...编辑此文件时保存它。

在第二步中,您必须以管理员身份运行cmd并键入以下代码:netsh http add urlacl url=http://*:port_Number/ user=everyone并按Enter键

在第三步中,您必须在防火墙上启用端口

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”

我希望这个答案对你有用

在此链接中更新Visual Studio 2015:https://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer


0
投票

此外,您应该禁用防病毒软件或管理它以打开系统上的80端口。


0
投票

知道你的局域网上的主机IP地址打开cmd并输入ipconfig和if xampp默认的监听端口是80然后例如10.0.0.5是你的主机IP地址从手机的网络浏览器输入10.0.0.5:80确保两者都连接到同一个局域网然而,webaddress尝试的默认端口是80。


0
投票

使用Keyoti的传送带(extensióndeVisual Studio)。 Extension visual studio

© www.soinside.com 2019 - 2024. All rights reserved.