简体   繁体   English

Windows Phone 8设备连接到Web API问题

[英]windows phone 8 device connecting to web api issue

i have a windows phone 8 device which i have unlocked for development . 我有一个Windows Phone 8设备,已将其解锁以进行开发。 i have successfully deployed the app to my windows phone 8 lumia 820, but i am unable to connect the app to the web api which is deployed on my machine . 我已成功将应用程序部署到Windows Phone 8 lumia 820,但无法将应用程序连接到部署在计算机上的Web API。 how can i do it? 我该怎么做?

basically i think that i will be needing the ip address of the device. 基本上我认为我将需要设备的IP地址。 how can i get it 我怎么才能得到它

   <bindings>
                <binding protocol="http" bindingInformation="*:30134:localhost" />
                <binding protocol="http" bindingInformation="*:30134:169.254.80.80" />
            </bindings>

The phone and your machine are different os's so localhost wont work (that would point to the phone). 手机和您的机器是不同的操作系统,因此localhost无法正常工作(这将指向手机)。 You need to make sure you machine is making the web api publically available on your network and then call it with your pcs ip that the api is available on. 您需要确保您的机器使网络api在网络上公开可用,然后使用您可以使用该api的pc ip对其进行调用。

Btw, if you want to get Ip adress from device, u can get through this code. 顺便说一句,如果您想从设备获取IP地址,则可以通过此代码。 Just run it and go step by step debug, and you will find IP. 只需运行它并进行逐步调试,您将找到IP。

        var hostnames = Windows.Networking.Connectivity.NetworkInformation.GetHostNames();
        foreach (var hn in hostnames)
        {
            if (hn.IPInformation != null)
            {
                string ipAddress = hn.DisplayName;
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM