从Android emulator访问IIS Express

从Android emulator访问IIS Express,android,iis-express,visual-studio-2017,Android,Iis Express,Visual Studio 2017,我知道类似的问题已经被问过很多次了,但我仍然不能让它正常工作。我希望能够从我的Visual Studio Android emulator访问主机上的IIS Express。我的网站的.vs\config\applicationHost.config文件中有以下绑定: <binding protocol="http" bindingInformation="*:7265:MyComp" /> <binding protocol="https" bindingInformatio

我知道类似的问题已经被问过很多次了,但我仍然不能让它正常工作。我希望能够从我的Visual Studio Android emulator访问主机上的IIS Express。我的网站的.vs\config\applicationHost.config文件中有以下绑定:

<binding protocol="http" bindingInformation="*:7265:MyComp" />
<binding protocol="https" bindingInformation="*:44300:MyComp" />
<binding protocol="http" bindingInformation="*:7265:10.0.2.2" />
<binding protocol="https" bindingInformation="*:44300:10.0.2.2" />
<binding protocol="http" bindingInformation="*:7265:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />

当我在主机上运行网站时,在运行的应用程序列表中,我看到列出了mycop和localhost的绑定,但没有列出10.0.2.2的绑定。在我的主机上,我可以使用mycop或localhost进行连接,而不会出现问题

在emulator中,我可以使用连接到主机上的IIS 7.5(非express),而不会出现任何问题。在我的模拟器中,我不能做的是连接到IIS Express中正在运行的站点,或者连接到该站点。我收到一个HTTP 400错误“请求主机名无效”。我确信这是因为我没有正确设置IIS绑定,但是我尝试的任何东西都不起作用。有什么想法吗


谢谢

你遗漏了一些基本事实。Android emulator上的10.0.2.2在主机上转换为127.0.0.1。因此,将绑定更改为

<binding protocol="http" bindingInformation="*:7265:127.0.0.1" />
<binding protocol="https" bindingInformation="*:44300:127.0.0.1" />

您还可以通过以下博客文章从绑定中删除主机头


在.NET项目中,转到项目设置|调试并在“应用程序url”字符串中将“localhost”替换为环回适配器“127.0.0.1”

为我工作。

您是否尝试了计算机名而不是IP。我确实尝试了,但发现了主机名未找到的DNS错误。我是Android开发者的新手,但我的印象是,你必须使用几个特定IP中的一个来连接主机……谢谢你的澄清。我最终在项目中切换到常规IIS而不是IIS Express,因此我无法测试您的答案,但这是有意义的。。。