S
S
Sergey2020-05-19 21:51:49
ASP.NET
Sergey, 2020-05-19 21:51:49

Get Microsoft Identity value/type?

I am using library ClaimsIdentity in Asp.net for user authentication.

var claims = new List<Claim>
                {
                    new Claim(ClaimsIdentity.DefaultNameClaimType, loginModel.NickName),
                    new Claim(ClaimsIdentity.DefaultRoleClaimType, loginModel.UserRole),
                    new Claim("UserID", loginModel.UserId.ToString()),
                };
                ClaimsIdentity claimsIdentity = new ClaimsIdentity(
                    claims,
                    "ApplicationCookie",
                    ClaimsIdentity.DefaultNameClaimType,
                    ClaimsIdentity.DefaultRoleClaimType);


In the future, I can use enclosing helpers in controllers, for example
[Authorize(Roles = "administrator")]
public IActionResult Index() { //to do
}


The question is the following. How can I get the same key/value from the cookie.DefaultRoleClaimType from the HttpContext, for example?

Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question