本文介绍了确定HttpClient中返回的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
在下面的代码中,我正在收到主页项目使用HttpClient ..
Hi,
In below code, I am getting homepage items using HttpClient..
使用相同的代码,如何检查返回是否有行或者它是零?
var client = new HttpClient();
client.BaseAddress = new Uri("https://www.domain.com/ws/populate_homepage.php?country=" + Convert.ToString(App.Current.Properties["EitharMemberCountryCode"]));
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("https://www.domain.com/ws/populate_homepage.php?country=" + Convert.ToString(App.Current.Properties["EitharMemberCountryCode"]));
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<List<EitharStory>>(data);
ObservableCollection<EitharStory> trends = new ObservableCollection<EitharStory>(result);
if (THERE_IS_DATA_THEN)
{ ---------- }
else
{ ---------- }
}
谢谢,
Jassim
推荐答案
这篇关于确定HttpClient中返回的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!