从Android模拟器进行IIS Express访问 [英] IIS Express access from Android emulator

查看:52
本文介绍了从Android模拟器进行IIS Express访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经问过很多类似的问题,但是我仍然无法使其正常运行.我希望能够从Visual Studio Android仿真器访问主机上的IIS Express.我的网站的.vs \ config \ applicationHost.config文件中具有以下绑定:

I know similar questions have been asked many times, but I still can't get it working correctly. I'd like to be able to access IIS Express on my host machine from my Visual Studio Android emulator. I have the following bindings in my .vs\config\applicationHost.config file for my website:

<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" />

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

When I run the website on my host, in the list of running applications, I see the bindings for MyComp and localhost listed, but not the ones for 10.0.2.2. On my host I can connect using MyComp or localhost without issue.

在模拟器中,我可以使用 http://10.0.2.2 连接到IIS 7.5(不表示)我的主机没有问题.在我的模拟器中,我无法执行的操作是连接到 http://10.0.2.2:7265 https://10.0.2.2:44300 是在IIS Express中运行的站点.我收到HTTP 400错误请求主机名无效".我确定这是因为我没有正确设置IIS绑定,但是我尝试的任何方法都没有用.有什么想法吗?

In the emulator, I can use http://10.0.2.2 to connect to IIS 7.5 (not express) on my host computer with no issue. In my emulator what I can't do is connect to http://10.0.2.2:7265 or https://10.0.2.2:44300 which is a site being run in IIS Express. I get an HTTP 400 error "The request hostname is invalid.". I'm sure this is because I don't have the IIS bindings set up correctly, but nothing I try works. Any ideas?

谢谢!

推荐答案

您错过了一些基本事实. Android模拟器上的10.0.2.2在主机上转换为127.0.0.1.因此,将绑定更改为

You missed a few basic facts. 10.0.2.2 on Android emulator is translated to 127.0.0.1 on the host. Thus, change your bindings to

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

您还可以通过关注此博客文章,从绑定中删除主机头,

You can also remove host headers from bindings by following this blog post,

https://blog.lextudio. com/how-to-let-android-emulator-access-iis-express-f6530a02b1d3

这篇关于从Android模拟器进行IIS Express访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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