无法从Visual Studio 2015 WIndows 10电话仿真器访问本地Web API [英] Unable to access local Web API from Visual Studio 2015 WIndows 10 Phone Emulator

查看:91
本文介绍了无法从Visual Studio 2015 WIndows 10电话仿真器访问本地Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个调用Web API的UWP电话应用。

I'm currently developing a UWP phone app which calls a Web API.

使用Visual Studio 2015(更新3)移动模拟器时,将调用Web API适用于仿真器版本10.0.10240.0和10.0.10586.0。但是,对于最新的模拟器版本 10.0.14393.0 ,我的API调用全部失败。

When using the Visual Studio 2015 (Update 3) mobile emulators, calls to the Web API work fine for emulator versions 10.0.10240.0 and 10.0.10586.0. However, for the latest emulator versions 10.0.14393.0 my API calls all fail.

我用来访问Web API的http地址在IIS Express下运行的 http:// localhost:64210 。使用模拟器的浏览器,我可以在10240/10586中访问此URL,但不能在14393中访问。

The http address I'm using to access the Web API, which is running under IIS Express, is http://localhost:64210. Using the emulator's browser, I can access this URL in 10240/10586, but not 14393.

我尝试遵循这篇文章(作者:安东尼·贝克(Anthony Baker)),以及该 MSDN文章,(两者均与Windows Phone 8模拟器),但均未解决。

I've tried following the relevant suggestions in this article by Anthony Baker, and this MSDN article, (both of which relate to the Windows Phone 8 emulator) but neither has led to a resolution.

我还注意到,在Hyper-V管理器中,14393仿真器的网络设置具有附加的网络适配器。 Microsoft仿真器NAT交换机,但我对此进行的实验表明,这并不是引起问题的原因。

I also noted that in the Hyper-V Manager the network setting for the 14393 emulator have the additional Network Adapter "Microsoft Emulator NAT Switch", but my experiments with this indicate it is not causing the problem.

有人可以提出解决此问题的方法吗?

Can anyone suggest a possible solution to this problem?

推荐答案

您可以尝试将 localhost更改为 10.0.2.2。

You can try changing "localhost" to "10.0.2.2".

Base在,如果您是从模拟器中调用本地主机,则需要调用10.0.2.2而不是原始的127.0.0.1。这是因为localhost指的是模拟器的localhost。

Base on this, if you are calling a local host from an emulator, you need to call 10.0.2.2 rather than the original 127.0.0.1. This is because localhost refers to the localhost of the emulator.

这篇关于无法从Visual Studio 2015 WIndows 10电话仿真器访问本地Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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