【发布时间】:2014-10-10 21:47:21
【问题描述】:
当我在应用程序运行时通过注册操作创建用户时,应用程序用户会获得 SecurityStamp。当我通过以下方式添加用户时:
if (!context.Users.Any()) {
System.Diagnostics.Debug.WriteLine("INSIDE");
var hasher = new PasswordHasher();
try {
var users = new List<ApplicationUser> {
new ApplicationUser{PasswordHash = hasher.HashPassword("TestPass44!"), Email = "informatyka4444@wp.pl", UserName = "informatyka4444@wp.pl"},
new ApplicationUser{PasswordHash = hasher.HashPassword("TestPass44!"), Email = "informatyka4445@wp.pl", UserName = "informatyka4445@wp.pl"}
};
users.ForEach(user => context.Users.AddOrUpdate(user));
context.SaveChanges();
} catch (DbEntityValidationException e) {
System.Diagnostics.Debug.WriteLine("EXC: ");
foreach (DbEntityValidationResult result in e.EntityValidationErrors) {
foreach (DbValidationError error in result.ValidationErrors) {
System.Diagnostics.Debug.WriteLine(error.ErrorMessage);
}
}
}
}
用户没有获得安全标记:
然后当我想登录时,我得到:
问题:如何为用户生成SecurityStamp?
【问题讨论】:
-
你为什么不改用
UserManager.CreateAsync();? -
@MohamadBataineh UserManager 对我不起作用。也许我在某个地方做错了:这里是主题 --> stackoverflow.com/questions/25354751/…
标签: c# asp.net-mvc entity-framework asp.net-identity seed