A
A
artshelom2019-01-20 23:38:33
ASP.NET
artshelom, 2019-01-20 23:38:33

How to pass a role from an authorized user in asp.net?

Where can I see where the data is filled in for an authorized user?
According to the standard, I can only take his name from an authorized user
@User.Identity.Name
, how can I make another object be passed and where to fill it in from an authorized user?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
Quelty, 2019-01-29
@Quelty

If you need to take the user's status from the user, then you can use the FirstOrDefault method.
example:
Context context = new Context();
User currentUser = context.User.FirstOrDefault( u => u.Name == User.Idenity.Name);
varrole = currentUser.Role;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question