0
我在VS2015中有一个Xamarin.Forms应用程序项目,它在我的网络中使用REST服务。 该项目的Android和iOS版本连接并从本地主机和我的网络中发布的服务获取数据,但Windows 8应用程序只在本地主机上工作,当我尝试从我的网络中的服务获取数据时,我只得到这个在输出控制台:无法从我的Windows 8.1应用程序发送HTTP请求
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.dll
ERROR An error occurred while sending the request.
是否存在我失踪的权限或安全限制?
我忘了说,Web服务是在端口5000是这样的: http://localhost:5000/api/clients或http://192.168.10.23:5000/api/clients 不知道有关或有任何政策限制在Win8的应用侦听的端口。
编辑2:
I think I should include the method where the exception is thrown:
public async Task<List<Client>> LoadClientsAsync(string query)
{
var Items = new List<Client>();
// RestUrl = http://192.168.10.100:5000/api/clients{0}
var sb = new System.Text.StringBuilder();
sb.Append("?q=");
sb.Append(System.Net.WebUtility.UrlEncode(query));
var uri = new Uri(string.Format(Constants.RestUrl, sb.ToString()));
try
{
var response = await httpclient.GetAsync(uri);
//Here is where exception is thrown
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
Items = JsonConvert.DeserializeObject<List<Client>>(content);
}
}
catch (Exception ex)
{
Debug.WriteLine(@" ERROR {0}", ex.Message);
}
return Items;
}