本文介绍了自Asp.net MVC 5认证,而无需使用Microsoft.AspNet.Identity.EntityFramework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建自定义的ASP.NET MVC 5验证不使用Microsoft.AspNet.Identity.EntityFramework的UserStore ??
How do you create a custom ASP.NET MVC 5 Auth without using the UserStore of Microsoft.AspNet.Identity.EntityFramework??
推荐答案
所有你需要做的是落实该Userstore为 Identity.Entityframework
使用相同的接口。
All you have to do is implement the same interfaces that the Userstore for Identity.Entityframework
uses.
用户
将是你的用户类
public class MyUserStore<TUser> :
IUserLoginStore<TUser, int>,
IUserClaimStore<TUser, int>,
IUserRoleStore<TUser, int>,
IUserPasswordStore<TUser, int>,
IUserSecurityStampStore<TUser, int>,
IUserStore<TUser, int>,
IDisposable where TUser : User
{
//Implement the interfaces you need
}
然后通过你的 MyUserStore
到的UserManager
每个请求
new UserManager<User, int>(new MyUserStore<User>(new MyContext()))
这篇关于自Asp.net MVC 5认证,而无需使用Microsoft.AspNet.Identity.EntityFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!