Kun*_*pal 5 java asp.net-mvc android android-emulator
我正在尝试从Android应用程序连接我本地IIS Express托管的WCF服务.目前,我正在模拟器上测试它.
该服务的本地URL是 http://locahost:40000/api/Authenticate
我知道localhost无法工作,我在代码中使用了10.0.2.2
post = new HttpPost("http://10.0.2.2:40000/api/authenticate");
Run Code Online (Sandbox Code Playgroud)
但客户端执行的响应是"无效的主机名"
我尝试编辑IIS Express的ApplicationHost.config并为10.0.2.2添加了一个绑定条目,但这也没有用
还有什么我想念的吗?
Kun*_*pal 10
我尝试了其他有用的东西,我在IIS Express applicationhost.config文件绑定部分中添加了我的系统的IP地址.
<bindings>
<binding protocol="http" bindingInformation="*:40000:localhost" />
<binding protocol="http" bindingInformation="*:40000:192.168.5.118" />
</bindings>
Run Code Online (Sandbox Code Playgroud)
我现在可以打电话给服务了
据我了解,10.0.2.2是127.0.0.1的别名,所以将其添加到您applicationhost.config的站点绑定中,例如
<site name="MySite" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="{yourpath}" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:26013:localhost" />
<binding protocol="http" bindingInformation="*:26013:127.0.0.1" />
</bindings>
</site>
Run Code Online (Sandbox Code Playgroud)
请记住,如果您使用的是Visual Studio,那么applicationhost.config您的网站的相关内容可能不在,c:\users\...而是位于.vs\config解决方案根目录的文件夹中.
| 归档时间: |
|
| 查看次数: |
8183 次 |
| 最近记录: |