本文介绍了如何在MVC中禁用用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何禁用用户帐户,而不是在mvc5中将其删除.我正在使用默认值中已提供的asp.net身份.
我希望管理员可以禁用不再需要的用户帐户,并保留与其他表关联的用户数据.
How can I disable an account of a user instead of deleting it in mvc5. I am using the asp.net identity that is already provided in the default.
I want that administrator can disable the user accounts that are not no longer required and keep the user data that is associated in other tables
推荐答案
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
// Enable Lock outs
manager.UserLockoutEnabledByDefault = true;
manager.MaxFailedAccessAttemptsBeforeLockout = 5;
// if you want to lock out indefinitely 200 years should be enough
manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromDays(365*200);
....
}
[ ^ ]
Source[^]
这篇关于如何在MVC中禁用用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!