I have built a server-side BLAZOR app based upon the sample project from Visual Studio 2019 Preview.
I have a menu item that navigates to my page using Navlink as:
<NavLink class="nav-link" href="StudentsExposedToStudents">
<span class="oi oi-list-rich" aria-hidden="true"></span> Students / Students
</NavLink>
The target page uses the design pattern from the sample and attempts to show a message whilst waiting for data as:
@if (intersections == null) { <p><em>Loading...</em></p> }
Typically the database service takes about 15 seconds to provide the data using an ASYNC method, but the advisory text "Loading..." is never presented.
What am I doing wrong?
This is my page
----------------------------------------------------------------
None
0 Points
1 Post
Page navigation does not honour ASYNC OnInitializedAsync design pattern
Apr 29, 2020 06:07 AM|graeme.thomson@avaxa.com|LINK
I have built a server-side BLAZOR app based upon the sample project from Visual Studio 2019 Preview.
I have a menu item that navigates to my page using Navlink as:
<NavLink class="nav-link" href="StudentsExposedToStudents">
<span class="oi oi-list-rich" aria-hidden="true"></span> Students / Students
</NavLink>
The target page uses the design pattern from the sample and attempts to show a message whilst waiting for data as:
@if (intersections == null) { <p><em>Loading...</em></p> }
Typically the database service takes about 15 seconds to provide the data using an ASYNC method, but the advisory text "Loading..." is never presented.
What am I doing wrong?
This is my page
----------------------------------------------------------------
@page "/StudentsExposedToStudents"
@using StrataDataAccess
@inject StrataService StrataService
<h1>List of students potentially exposed to infectious students</h1>
@if (intersections == null) { <p><em>Loading...</em></p> }
else
{
<table class="table">
<thead>
<tr>
<th> Exposed Student </th>
<th> Contact Student Name </th>
<th> Session Date </th>
<th> Start Time </th>
<th> End Time </th>
<th> Timetable Group </th>
<th> Exposed Hours </th>
<th> </th>
</tr>
</thead>
<tbody>
@foreach (var item in intersections)
{
<tr>
<td> @item.StudentName </td>
<td> @item.ContactName </td>
<td> @item.SessionStart.ToString("dd-MMM-yyyy") </td>
<td> @item.SessionStart.ToString("H:mm") </td>
<td> @item.SessionEnd.ToString("H:mm") </td>
<td> @item.TimetableGroupName </td>
<td> @item.ExposureHours.ToString("0.##") </td>
</tr>
}
</tbody>
</table>
}
@code {
public IEnumerable<StrataDataAccess.StudentsExposedToStudents>
intersections = null;
protected override async Task OnInitializedAsync()
{
intersections = null;
intersections = await StrataService.GetListOfStudentStudentIntersectionsAsync();
intersections = intersections.OrderBy(s => s.StudentName)
.ThenBy(s => s.ContactName);
}
}
----------------------------------------------------------------