Where is HttpContent.ReadAsAsync?

后端 未结 6 1135

I see in tons of examples on the web using the new HttpClient object (as part of the new Web API) that there should be HttpContent.ReadAsAsync

6条回答
  •  执念已碎
    2020-11-29 17:51

    I have the same problem, so I simply get JSON string and deserialize to my class:

    HttpResponseMessage response = await client.GetAsync("Products");
    //get data as Json string 
    string data = await response.Content.ReadAsStringAsync();
    //use JavaScriptSerializer from System.Web.Script.Serialization
    JavaScriptSerializer JSserializer = new JavaScriptSerializer();
    //deserialize to your class
    products = JSserializer.Deserialize>(data);
    

提交回复
热议问题