Problem when refreshing certain pages

OK. I am in. I don't see any exceptions but the DataGrids do disappear on refresh. Will investigate why.

1 Like

The reason the Grid is invisible and the button is disabled is because the following expression is false during refresh:

@(Security?.User?.role?.registrationDocumentViewRecords ?? false)

Check this gif:

During normal navigation this expression is true during refresh it becomes false.

This happens because the security service is not initialized for some reason after refresh. Unfortunately I cannot determine why because if I break with the debugger in the Layout it always works as it should. The funny thing is that I cannot reproduce such behavior in a regular Radzen application - the code in the layout always runs before the code from the page and the security service is initialized.

1 Like

I see. Yeah, my security service definitely needs some upgrades right now. I will try and check why is it taking so long to load the user after refreshing.

Thanks a lot for your efforts in helping to fix my app. Happy New Year!

I don't think it is loading the user that is the problem. For some reason in your application the code in the page executes before the layout (I think it is supposed to be the other way around). As a result the security service is not initialized yet. If you put await Security.InitializeAsync(AuthenticationStateProvider); in the Load event of the page things start to work. Still cannot understand why this doesn't happen in regular Radzen application.

I found out why I couldn't reproduce it locally. It seems to be a bigger problem. Security.InitializeAsync should be invoked in the page and the layout as there is no guarantee the layout executes first. We will test if this does not cause any other problems. In the past we used to do it but it caused EF issues for accessing the context from different threads.

2 Likes

Did you test the provided fix in 2.56.10 using my app? It's completely broken because of the simultaneous database query from the layout and the page:

I will downgrade to 2.56.9.

Yes we did. However since your SecurityService is ignored it doesn't include the fix for simultaneous db requests.

My apologies, there are so many files in the ignore list that I forget half of them. After adding the SemaphoreSlim code, the errors are gone. Thanks!

We may be having a solution for the ignore files problem :wink: It is good that we have your project so we can test (you know what).

1 Like