Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

hi,my HttpClient not working.why? Any one can help me? Thanks

$
0
0

This is my xamrin.forms code below:

public async Task<TResult> GetAsync<TResult>(string uri, string token = "")
    {
        HttpClient httpClient = CreateHttpClient(token);
        HttpResponseMessage response = await httpClient.GetAsync(uri);

        await HandleResponse(response);
        string serialized = await response.Content.ReadAsStringAsync();

        TResult result = await Task.Run(() => this.GetResultObject<TResult>(serialized));

        return result;
    }

And there is my Api code:
[HttpGet]
public async Task GetTest()
{
return await Task.FromResult("打算斯大林");
}

The host is localhost, I am now replaced with ip:172.0.0.1, my api works fine in Postman and Chrome.
But I use the android emulator that comes with xf, but the program has been quit, and I can't locate the exception. why?

Thanks.


Viewing all articles
Browse latest Browse all 77050

Trending Articles