gpt4 book ai didi

asp.net - .net 4.5.1 ASP.NET MVC 5 中的用户锁定

转载 作者:行者123 更新时间:2023-12-03 15:20:21 25 4
gpt4 key购买 nike

因此,在新的 .Net Framework 4.5.1 AspNetUser 表中,在有限次数的尝试失败后,没有将用户锁定的列。是否有为此目的构建的框架或解决方案来替换曾经存在于以前的 .net 框架中的功能?还是我必须自己建立?

最佳答案

在即将发布的 2.0 Identity 版本中,支持帐户锁定

配置:

    manager.UserLockoutEnabledByDefault = true; // Enables ability to lockout for users when created
manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5);
manager.MaxFailedAccessAttemptsBeforeLockout = 5;

用法:
manager.IsLockedOutAsync(user.Id) // Check for lockout
manager.ResetAccessFailedCountAsync(user.Id); // Clear failed count after success
manager.AccessFailedAsync(user.Id); // Record a failure (this will lockout if enabled)
manager.SetLockoutEnabled(user.Id, enabled) // Enables or disables lockout for a user

关于asp.net - .net 4.5.1 ASP.NET MVC 5 中的用户锁定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22483316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com