本文介绍了用户锁定在.NET 4.5.1 ASP.NET MVC 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,在新的.Net框架4.5.1 AspNetUser表没有列锁定用户出有限数目的不成功尝试后。是否有专为目的,以取代曾经在previous .NET框架中存在的功能框架或解决方案?还是我必须建立自己的
So in the new .Net Framework 4.5.1 AspNetUser table does not have a column to lock user out after a finite number of unsuccessful attempts. Are there frameworks or solutions built for that purpose to replace the functionality that once existed in previous frameworks? Or do I have to build my own?
推荐答案在即将到来的2.0版本的身份,有一个帐户锁定的支持
In the upcoming 2.0 Identity release, there is support for Account Lockout
配置:
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更多推荐
用户锁定在.NET 4.5.1 ASP.NET MVC 5
发布评论