在Xamarin.Android REST服务中的Get方法
- 论坛
- 在Xamarin.Android REST服务中的Get方法
33 浏览
在Xamarin.Android REST服务中的Get方法
我想在我的Xamarin.Android应用程序中使用GetStringAsync方法从我的API获取数据,但是遇到以下错误:
System.Net.WebException: 错误:连接失败(连接被拒绝)
我的代码:
private static async void MainAsync() { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:57558/"); var getResponse = await client.GetStringAsync("/api/home"); var getTask = client.GetStringAsync("/api/home"); await getTask.ContinueWith((antecidentTask) => { var result = antecidentTask.Result; }); }