Application Login Delay

I'm having a small issue with RBS that I didn't have with Radzen Studio. I have a very standard login procedure set up, no changes from when security gets initially set up. In the MainLayout, I added a dropdown to the header. I added 2 columns to the aspnetusers table using migration. They are AccountID and StoreID. Each comes from a different table ("Accounts" and "Stores"). The dropdown pulls its list from the store table (filtered by AccountID). When a store is selected it saves the StoreID to a global variable (storeID) so that I can filter crud pages and only show store data base on the selected store. This all works fine in both RBS and Radzen Studio except that in RBS there is a significant delay during login that doesn't happen in Radzen Studio. I have tested and if I remove the dropdown and the GetStore, it works fine. Should I approach this differently to avoid this delay (it is significant)

It's only 2 lines of code:

    protected override async Task OnInitializedAsync()
    {
        Globals.storeID=Security.User.StoreID;
        stores = await AccelerateDataService.GetStores();
    }

I did add a GlobalService to access the variable, but it has no affect on the login process unless I have the 2 lines in the OnInitializeAsync().

stores is generated as follows:

protected System.Linq.IQueryable<Accelerate.Models.AccelerateData.Store> stores;

Hi @daveg1466,

If the app is the same then it should behave the same. Both tools just run the app without anything extra.

It looks that GetStore is causing the delay. What does it do?

All it has is a list of stores StoreID (long) and StoreName (nvarchar(125)) by account, so also includes AccountID (long). AspNetUsers has both those columns for each user. I filter the store table by AccountID which I get from Security.User (Security.User.AccountID) that I added using migration. Then I list the filtered stores in a dropdown. When a store is selected, the StoreID is saved in Globals.storeID. This way I can you it in filtering in any other crud pages I set up. Would it lag less if I used ToList()?

the GetStore line looks like this with the filter in place

stores = await AccelerateDataService.GetStores(new Radzen.Query { Filter = "i => i.AccountID == @0", FilterParameters = new object { Security.User.AccountID } });

There are currently only 5 rows in the table

It is definitely the GetStore that is causing it. I commented it out and removed the dropdown and it ran fine. I uncommented it and did not put the dropdown back and the delay came back.

|StoreID|bigint|Unchecked|
|AccountID|bigint|Unchecked|
|StoreName|nvarchar(125)|Unchecked|
|StoreImage|nvarchar(MAX)|Checked|
|StoreActive|bit|Unchecked|

Those are literally the only columns in the table

I though maybe it was the StoreImage column so I deleted it and still the same delay.

As I look for ways around this, I have noticed that it is only on the first load. If I logout and log back in (without closing the browser), it loads immediately. So it must be during the first initialization of the connection string.

After a nights worth of research, it seems that Blazor Server is waiting to render the page until after the data is loaded (no matter the size of the table).

I found the quickest way to solve this is adding "await Task.Delay(1)" before the GetStore. This resolves the issue. Putting this here for anyone else needing a solution to this kind of problem!

Another note on this. the await Task.Delay(1) cannot be put in the OninitializeAsync Method. I had to create another method that used protected async System.Threading.Task.Task and then load this method from OninitializeAsync. But it works fine.