Username return anonymous

Hello there,

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.



I think I'm missing a link. Can you help me out?


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.

I can't reproduce this problem in a sample application. I dragged a label before the profile menu and set its Text property to ${Security.User.Name}.

Then ran the app and logged in with a user which is not admin/admin. It worked as expected.

Find attached my test application. It uses the Radzen Sample database (available via the Create sample schema button when you edit the data source) (29.3 KB)

I've tried to do the same with another application and I'm still getting anonymous. I will look further into it and give you more details if possible.

BTW, I can't import this into my Radzen for some reason. I think it's missing the correct file to import it.

Are you using an up-to-date version of Radzen? You can send us your application as well as a database script and we will check what's going on.

@korchev, I've send an email to with my application and further details.

Thanks for the help!

I can't send it for some reason. The mail is getting returned to me.

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.

I've tried to send it again with a Google Drive link.

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

user = await userManager.FindByNameAsync(name);

seems to solve the problem.

1 Like

@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!

Update: It's working as expected. Thanks again!