admin管理员组文章数量:1287119
I am encountering an issue when trying to use the HttpClient in my .NET MAUI application. When making an API call using HttpClient, I receive a response from the server, but the children (or response data) cannot be evaluated correctly, resulting in empty objects or no data being displayed in the UI.
public async Task<List<ArticleViewModel>> GetAllArticles()
{
try
{
using (var _httpClient = new HttpClient())
{
// Send GET request to the API
string urlEndpoint = _baseUrl + "/api/Articles/GetArticles";
var response = await _httpClient.GetStringAsync(urlEndpoint);
return JsonConvert.DeserializeObject<List<ArticleViewModel>>(response);
}
}
catch (Exception ex)
{
return new List<ArticleViewModel>(); // Return empty list on exception
}
}
Actual Result: The response is received, but the children (or response data) cannot be evaluated, resulting empty list.
I tried with Postman and another console application, and everything seems fine in both cases. Only in .NET MAUI am I getting the error message
本文标签: NET MAUI HttpClient ResponseChildren Could Not Be EvaluatedStack Overflow
版权声明:本文标题:.NET MAUI HttpClient Response - Children Could Not Be Evaluated - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741259310a2367299.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论