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

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

问题描述

我设法使用以下指南启用了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.

目前,从设备运行时,Web客户端会发出请求,但从未完成,这会使应用程序挂起.

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

然后您的设备可以向发出请求

Then your device can make requests to

<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.

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

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