获取 Xamarin Android 设备调用运行 Localhost 的 ASP.NET Web APi [英] Get Xamarin Android Device calling ASP.NET Web APi running Localhost

查看:13
本文介绍了获取 Xamarin Android 设备调用运行 Localhost 的 ASP.NET Web APi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法使用以下指南使我的 VS2015 Android 模拟器能够访问在我的本地主机上运行的 ASP.NET WEP API,这很棒:-

I've managed to use the following guide for enabling my VS2015 Android Emulator access to a ASP.NET WEP API running on my local-host which is great :-

http://briannoyesblog.azurewebsites.net/2016/03/06/calling-localhost-web-apis-from-visual-studio-android-emulator/

但我还想配置我的 Xamarin 应用程序,使我的外部 android 设备能够访问 web api.

But i would also like to configure my Xamarin application for enabling my external android device the same access to the web api.

目前,当从设备运行时,webclient 发出请求但它永远不会完成,这导致应用程序挂起.

At present, when running from device, the webclient makes the request but it never completes, which leaves the application hanging.

有谁知道我如何才能做到这一点?

Does anyone know how I can achieve this?

推荐答案

检查您的 applicationhost.config,找到您的 WebApi 的绑定.应该是这样的:

Check your applicationhost.config, find the bindings for your WebApi. There should be something like this:

<binding protocol="http" bindingInformation="*:<your-port>:localhost" />

为外部请求添加绑定:

<binding protocol="http" bindingInformation="*:<your-port>:*" />

然后您的设备可以向

<your-network-IP-of-your-machine>:<your-port>

您的设备和您托管 WebApi 的机器需要在同一网络中,例如您当地的 WiFi.

Your device and your machine hosting the WebApi needs to be in the same network, e.g. your local WiFi.

这篇关于获取 Xamarin Android 设备调用运行 Localhost 的 ASP.NET Web APi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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