Joh*_* Po 6 c# asp.net asp.net-mvc owin asp.net-mvc-5
如何在不使用Microsoft.AspNet.Identity.EntityFramework的UserStore的情况下创建自定义ASP.NET MVC 5 Auth?
您所要做的就是实现用户存储所Identity.Entityframework使用的相同接口。
User将是您的用户类别
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
}
Run Code Online (Sandbox Code Playgroud)
然后将您的传递到每个请求MyUserStore中UserManager
new UserManager<User, int>(new MyUserStore<User>(new MyContext()))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5124 次 |
| 最近记录: |