有人可以解释一下,声称机制在新的ASP.NET身份核心中意味着什么?
我所看到的,有一个AspNetUserLogins表,其中包含UserId,LoginProvider和ProviderKey.
但是,我仍然无法理解或找到有关何时将数据添加到AspNetUserClaims表中以及此表用于何种情况的任何信息?
我正在使用Entity Framework 5 Database First方法开发MVC 5 Web应用程序.我正在使用OWIN进行用户身份验证.下面显示我的帐户控制器中的登录方法.
public ActionResult Login(LoginViewModel model, string returnUrl)
{
if (ModelState.IsValid)
{
var user = _AccountService.VerifyPassword(model.UserName, model.Password, false);
if (user != null)
{
var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, model.UserName), }, DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Name, ClaimTypes.Role);
identity.AddClaim(new Claim(ClaimTypes.Role, "guest"));
identity.AddClaim(new Claim(ClaimTypes.GivenName, "A Person"));
identity.AddClaim(new Claim(ClaimTypes.Sid, user.userID)); //OK to store userID here?
AuthenticationManager.SignIn(new AuthenticationProperties
{
IsPersistent = model.RememberMe
}, identity);
return RedirectToAction("Index", "MyDashboard");
}
else
{
ModelState.AddModelError("", "Invalid username or password."); …Run Code Online (Sandbox Code Playgroud) asp.net authentication asp.net-mvc claims-based-identity asp.net-mvc-5
我通过在ApplicationUser派生自的类中添加几个字段来扩展ASP NET标识架构IdentityUser.我添加的领域之一是FullName.
现在,当我写的时候User.Identity.Name,它给了我用户名,我正在寻找类似的东西User.Identity.FullName应该返回我添加的FullName.
不确定,如何实现这一点,我们将非常感谢任何指导.
谢谢.