You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was a strange behaviour, so I discovered that all post is not loaded correctly on startup.
So I added a fix for this to wait for the posts to finish.
To recreate the issue: Start application and add a new post. Restart the application, the new post is not shown or not all posts exists in list. Result: List does not contain all posts. Expected result: All items in list is shown. File: BlogController.cs
public async Task<IActionResult> Index([FromRoute]int page = 0){
var posts = await _blog.GetPosts(_settings.Value.PostsPerPage, _settings.Value.PostsPerPage * page);
var result = Task.FromResult(posts).Result; //<----- Wait for the posts to finish
ViewData["Title"] = _manifest.Name;
ViewData["Description"] = _manifest.Description;
ViewData["prev"] = $"/{page + 1}/";
ViewData["next"] = $"/{(page <= 1 ? null : page - 1 + "/")}";
return View("~/Views/Blog/Index.cshtml", result); //<----- result
}
The text was updated successfully, but these errors were encountered:
This was a strange behaviour, so I discovered that all post is not loaded correctly on startup.
So I added a fix for this to wait for the posts to finish.
To recreate the issue: Start application and add a new post. Restart the application, the new post is not shown or not all posts exists in list.
Result: List does not contain all posts.
Expected result: All items in list is shown.
File: BlogController.cs
The text was updated successfully, but these errors were encountered: