Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor rendering after computation or call

$
0
0

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:

enter image description here

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.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>