making my first steps in Blazor!
I have my page Test.razor with a simple grid:
<table class="table">
<thead>
<tr>Message</tr>
</thead>
<tbody>
@foreach (var exception in Exceptions)
{
<tr>exception.Message</tr>
}
</tbody>
</table>
and my logic:
public partial class Test
{
public List<TestEventModel> Exceptions { get; set; }
protected override async void OnInitialized()
{
var exceptionsResponse = (await http.GetAsync("TestController")).Content.ReadAsStringAsync();
Exceptions = JsonConvert.DeserializeObject<List<TestEventModel>>(await exceptionsResponse);
}
}
Problem: Unhandled exception rendering component: Object reference not set to an instance of an object.
Exception occurring on the line :
@foreach (var exception in Exceptions)
But according to the lifecycle it should start rendering only after the execution of OnInitialized:
If indeed I initialize the list in a constructor for example, problem is not there, but of course the list will be empty and not showing the result of my http call.



Exceptionsis not null after you assign it? - Kirk Woll