I have the following code to populate a data grid:
@implements IDisposable@inject IRecordServices RecordServices@inject DialogService DialogService@inject IJSRuntime js@inject Radzen.NotificationService NotificationService@inject PersistentComponentState ApplicationState@rendermode InteractiveServer..............DataGrid populated with records............... IEnumerable<RecordEntity>? records; RadzenDataGrid<RecordEntity> grid = new RadzenDataGrid<RecordEntity>(); PersistingComponentStateSubscription rendering = new PersistingComponentStateSubscription(); protected override async Task OnInitializedAsync() { rendering = ApplicationState.RegisterOnPersisting(() => { ApplicationState.PersistAsJson(nameof(records), records); return Task.CompletedTask; }); if (!ApplicationState.TryTakeFromJson(nameof(records), out IEnumerable<RecordEntity>? restored)) records = await GetAllRecordsForGrid(); else records = restored; } private async Task<IEnumerable<RecordEntity>> GetAllRecordsForGrid() { return await RecordServices.GetRecordEntities(); } public void Dispose() { rendering.Dispose(); }OnInitializedAsync() is supposed to run twice and it normally does, but when I try to add the RegisterOnPersisting(), the OnInitializedAsync() only runs once and then my web application is rendered but it gives a generic server error and the page is not interactable.
I really want to get this Persist State working so the component doesn't render twice.
What am I doing wrong?