错误请求 - 通过wifi从手机连接到localhost时无效的主机名 [英] Bad Request- Invalid Hostname while connect to localhost via wifi from mobile phone

查看:1060
本文介绍了错误请求 - 通过wifi从手机连接到localhost时无效的主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试连接笔记本电脑的localhost时,我收到错误请求 - 无效主机名[HTTP ERROR 400]
实际上,我正在学习使用jQuery Mobile开发移动网络。
我想看看网络的布局是否适合我的手机尺寸。

I get the Bad Request- Invalid Hostname [HTTP ERROR 400] while trying connect my laptop's localhost. Actually, I am learning to develop mobile web using jQuery Mobile. I want to see the layout of the web whether fit my phone size.

我添加了Visual Studio以这种方式给出的端口号:

控制面板>防火墙>高级设置>退回规则>新规则。

然后,我输入 ipconfig <获取我的IP地址/ strong>在命令提示符下。

之后,我使用我的Android手机浏览器(Mozilla 5.0)并输入链接192.XXX.XXX.XXX:57976。

i have added the port number which given by the Visual Studio with this way:
Control Panel> Firewall> Advanced Settings> Inbounce Rules> New Rule.
Then, i get my IP address by typing "ipconfig" at Command Prompt.
After that, I use my Android phone browser (Mozilla 5.0) and enter the link 192.XXX.XXX.XXX:57976.

I我读过类似的问题,但我无法得到解决方案。
有些人认为此错误与IIS设置有关。
但我无法获得IIS设置的解决方案。
希望你们能帮助我解决这个问题。

I have read similar questions but I can't get the solution. Some people think this error is related to the IIS settings. But I can't get the solution of the IIS settings. Hope you guys can help me solve this problem.

推荐答案

步骤1:添加Windows防火墙的入站规则



Step 1: Add Inbound Rule of Windows Firewall


  1. 打开 Windows具有高级安全性的防火墙

  2. 在左侧面板中,右键单击入站规则> 新规则

  3. 规则类型:端口

    协议和端口:TCP

    具体本地端口:57976

    操作:允许连接

    个人资料:全部勾选(域名,私人,公开)

    姓名:姓名,说明(可选)

  4. 完成。



  1. Open the Windows Firewall with Advanced Security.
  2. At the left panel, right click on Inbound Rule > New Rule
  3. Rule Type: Port
    Protocol and Ports: TCP
    Specific local ports: 57976
    Action: Allow the connection
    Profile: Tick all (Domain, Private, Public)
    Name: Name, Description(optional)
  4. Finish.



第2步:IIS或IIS Express



添加IIS管理器的绑定


  1. 打开 IIS管理器

  2. 在左侧面板中,转到网站> 默认网站

  3. 在右侧面板中,单击绑定。然后,弹出新对话框。

  4. 在弹出对话框中,单击添加按钮。输入端口号和主机名。

    对于我的情况,

    端口 = 57976;

    主机名 = 192.XXX.XXX.XXX(我的IP地址)



  1. Open the IIS Manager.
  2. At the left panel, Go to Sites > Default Web Sites.
  3. At the right panel, click on the Bindings. Then, the new dialog pop ups.
  4. At the pop-up dialog, click on the "Add" buttons. Input the port number and the hostname.
    For my case,
    port = 57976;
    hostname = 192.XXX.XXX.XXX (my IP address)

添加IIS Express的绑定(Visual Studio)


  1. 停止当前站点

  2. 对于 Visual Studio 2015 ,更改IIS配置在您的项目文件夹 C:\Projects \< ProjectName> \.vs \config\applicationhost.config

  3. 对于以前版本的Visual Studio 2015 ,请更改IIS Express文件夹下的IIS配置 C:\Users \<您的个人资料名称> \文档\ IISExpress\config\applicationhost.config

  4. 应用程序中ionhost.config ,按端口号搜索(我的情况是57976),然后再绑定一个你的IP地址

  1. Stop the current Site
  2. For Visual Studio 2015, change the IIS config under your project folder C:\Projects\<ProjectName>\.vs\config\applicationhost.config‌​.
  3. For previous version of Visual Studio 2015, change the IIS config under IIS Express folder C:\Users\<your profile name>\Documents\IISExpress\config\applicationhost.config
  4. In applicationhost.config, search by the port number (for my case is 57976), then one more binding with your IP Address

    <site name="Web(1)" id="9">
      <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="E:\abc\project\dev\web" />
      </application>
      <bindings>
        <binding protocol="http" bindingInformation="*:57976:localhost" />
        <binding protocol="http" bindingInformation="*:57976:192.XXX.X.XXX" />
      </bindings>
    </site>




更新:



对于Windows 10或Visual Studio 2015用户,
您可能会收到以下错误消息:

Updated:

For windows 10 or Visual Studio 2015 users, you may get the error message below:

Unable to launch the IIS Express Web server, Failed to register URL, Access is denied

解决方案:


  1. 关闭Visual Studio

  2. 右键单击Visual Studio>以
    管理员身份运行




参考: https://azure.microsoft。 com / zh-CN / documentation / articles / mobile-services-dotnet-backend-how-to-configure-iis-express /

这篇关于错误请求 - 通过wifi从手机连接到localhost时无效的主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆