I'm trying to return the Username value to my application but instead it's returning "Anonymous".
I've tried both ${Security.User.Name} and ${Security.User} but both return Anonymous.
When I login with admin admin, the current user is shown as admin.
This should have worked. Radzen returns Anonymous when the security service is not initialized yet (in order to prevent the User property from returning null). Where is this expression used? In a page or in a layout? Are any files in the code generation ignore list?
@korchev, the expression is used in a label component within a layout screen. I haven't ignored any files into the list so the problem should be somewhere else. Can't seem to figure out where it goes wrong.
Find attached my test application. It uses the Radzen Sample database (available via the Create sample schema button when you edit the data source).BlazorServerNET5.zip (29.3 KB)
We didn't get any email from you. Please check the attachment size as our email server won't allow bigger files. Delete any obj and bin directories to keep it smaller. Alternatively upload the app to some cloud storage (Google Drive, One Drive, Dropbox etc) and share the link over email.
We got the files and reproduced the problem. For some reason the Email of all users is NULL in the AspNetUsers table. How did you create those users? This is why the SecurityService cannot find the user. It uses the following code:
user = await userManager.FindByEmailAsync(name)
which returns null for every user.
Using the code generation ignore list and changing that code to
@korchev, thanks! For my application it isn't necessary to create an Email for the users so I just kind of ignored that. I think that's where it went wrong.
I will implement the code you said. Thanks for the help!