I have a component that has multiple method calls in the OnInitializedAsync
method.
One method is giving problems when the data it returns is large.(Estimate of 4mb when testing the return data in postman.).
The retrieval of the data seems fine, but the issue I am experiencing is that after the call is finished, it takes the UI long to respond/update. In some instances I experience that the entire page freezes.
When I remove this method or the data is small, I experience no problems.
The info that gets returned is mainly a string of a html formatted document created from a htmleditor component.
The data from this call gets displayed in the component.
The method in question is as follows –
protected async Task GetAnswers()
{
var requestMessage = new HttpRequestMessage(HttpMethod.Get, "api/api/GetAnswersByQuestionID/" + QuestionId);
var response = await _httpClient.SendAsync(requestMessage);
if (response.IsSuccessStatusCode)
{
var JsonResult = await response.Content.ReadAsStringAsync();
answers = JsonConvert.DeserializeObject<List<Answer>>(JsonResult);
answers = answers.OrderByDescending(a => a.AnswerId).ToList();
}
}
I have tried loading this in after the other data is loaded, but the issue still persists.
Is there anything I need to take into consideration or what are the possible solutions for these performance issues?
Any help regarding this would be appreciated. If there is anything else required, I will provide on request.