windows phone 8.1 中的 Http 获取请求

Http Get Request in windows phone 8.1

我是 windows phone 8.1 应用的新手 developement.i 在使用 httpclient get request 从 API 获取响应时遇到了问题。谁能告诉我最好的执行方式来自服务器的获取请求 windows phone 8.1..提前致谢

希望以下内容对您有所帮助

try{

 var client = new HttpClient();


    var uri = new Uri("your URI"); 

    //Call. Get response by Async
    var Response = await client.GetAsync(uri);

    //Result & Code
    var statusCode = Response.StatusCode;

    //If Response is not Http 200 
    //then EnsureSuccessStatusCode will throw an exception
    Response.EnsureSuccessStatusCode();

    //Read the content of the response.
    //In here expected response is a string.
    //Accroding to Response you can change the Reading method.
    //like ReadAsStreamAsync etc..
    var ResponseText = await Response.Content.ReadAsStringAsync();
}

catch(Exception ex)
{
    //...
}