When I run your sample it works as expected. Mine still does not fire off the Authenticated method until after it goes to the OnInitializedAsync and then the Authenticated gets fired.
So the sequence is:
MainLayoutComponent.OnInitializedAsync
MainPageComponent.OnInitializedAsync
MainLayoutComponent.Authenticated
Were you able to test this out? It show's Anonymous instead of the username. If I use the Admin username it works fine but if I use a real username from the security database then it shows Anonymous.
In my production program it shows Anonymous and the my real username about 1 second later. I can send you a video of that if you wish.
Thanks for trying but I'm wondering if you can try one more thing out. This sample just has the username displayed on the MainLayout. When using Admin it displays correctly. When using A real username from the data base it displays Anonymous.
Not sure if this is related however we will add in the next update FindByNameAsync() in the security service if FindByEmailAsync() fails to find the user.
enchev, that would be good even if it does not fix my problem that I sent you. I currently do the work around that kim suggested in my production version because I use the email as the login.
But, that fix is not relevant to the current problem. And, I don't know why when you run the program using a username from the database that it works for you but I get Anonymous.
Update: I may be wrong and the work-around may work. I'll try that out again on the version I sent you.
FindByNameAsync does take care of retrieving the correct user. I should have known this because this is what I have in my production version. However, the real problem is the sequence of methods that called when admin is used as opposed to a real username. Here is where I have breakpoints:
When admin is used the sequence is:
1.MainLayoutComponent: OnInitializedAsync
2.MainLayoutComponent: Authenticated
3.GendersComponent: OnInitializedAsync
4.MainLayoutComponent: Authenticated
When a real username from the database is used the sequence is:
1.MainLayoutComponent: OnInitializedAsync
2.GendersComponent: OnInitializedAsync
3.MainLayoutComponent: Authenticated
4.MainLayoutComponent: Authenticated
I need to have the real usernames use the same calling sequence as the admin username.
My previous problem with the Anonymous user may be related to this problem. When I made my application, I made an user named 'Admin' with a password that isn't 'admin' (didn't know that admin/admin existed back then). I guess the generated code is stressing when you make an user with the same name as the admin user. Don't know for sure though. Hopefully this helps a bit!