作者:mobiledu2502907083 | 来源:互联网 | 2023-05-17 17:39
IhaveusedOWINauthenticationinmyapplication.我在应用程序中使用了OWIN身份验证。LoginAction登录操作varclai
I have used OWIN authentication in my application.
我在应用程序中使用了OWIN身份验证。
Login Action
登录操作
var claims = new List();
claims.Add(new Claim(ClaimTypes.Name, result.UserFirstName));
claims.Add(new Claim(ClaimTypes.Sid, result.UserID.ToString()));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCOOKIE);
I want to access the UserName and UserID from different action. How can I access the values which is added in the claims?
我想从不同的操作访问用户名和用户id。如何访问索赔中添加的值?
Update I have tried
更新我试过
var claims = new List();
claims.Add(new Claim(ClaimTypes.Name, result.UserFirstName + " " + result.UserLastName));
claims.Add(new Claim(ClaimTypes.Sid, result.UserIDNumber.ToString()));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCOOKIE);
var authenticatiOnManager= Request.GetOwinContext().Authentication;
authenticationManager.SignIn(identity);
var claimsPrincipal = new ClaimsPrincipal(identity);
Thread.CurrentPrincipal = claimsPrincipal;
I can view the values inside the quick window. But even though I couldn't access the value. How to get the value?
我可以查看快速窗口内的值。但即使我无法访问这个值。如何获得价值?
2 个解决方案