OTDL
OTDL
CC#
Created by OTDL on 1/3/2025 in #help
C# api response infinitly loading and stops debuging with working api and blazor
I am building an admin dashboard for my webshop with blazor and an api. I know my api is working correctly because i already have working crud pages for products, categories and subcategories. I have a method in categories controller that returns how many products there are in a category GetProductsByCategory(Guid id). When hitting this line var response = await _httpClient.GetAsync($"{ApplicationConstants.ApiUrl}Categories/{id}/products"); in the debugger it doesnt go to the next line instead it stops debugging and on my categories page it loads infinitly so i cant debug what the var response is because it stops. So i made a second method that doesnt return a json array but just an int but its the same thing. Its only on these 2 endpoints this happens Btw my page fully works if i remove the count functionality from this page. Ive tested the endpoints in my api and with postman and both get a 200 with either an empty array or 0 depending on what method public async Task<IQueryable<JsonProduct>> GetProductsByCategory(Guid id) { await AddAuthorizationHeaderAsync(); var response = await _httpClient.GetAsync($"{ApplicationConstants.ApiUrl}Categories/{id}/products"); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var productCollection = JsonSerializer.Deserialize<List<JsonProduct>>(json); return productCollection.AsQueryable(); } public async Task<int> GetProductAmountByCategory(Guid id) { await AddAuthorizationHeaderAsync(); var response = await _httpClient.GetAsync($"{ApplicationConstants.ApiUrl}Categories/{id}/productamount"); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var productCount = JsonSerializer.Deserialize<int>(json); return productCount; }
6 replies