![](/img/trans.png)
[英]Microsoft.AspNet.Identity and Microsoft.AspNet.Identity.EntityFramework in .NET Standard 2.0
[英]Custom Asp.net mvc 5 authentication without using Microsoft.AspNet.Identity.EntityFramework
如何在不使用Microsoft.AspNet.Identity.EntityFramework的UserStore的情况下创建自定义ASP.NET MVC 5 Auth?
您所需要做的就是实现Userstore for 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
}
然后将每个请求将MyUserStore
传递到UserManager
new UserManager<User, int>(new MyUserStore<User>(new MyContext()))
您可以从GitHub上的以下项目中获取UserStore.cs模板,并根据需要对其进行调整,这将使您摆脱对Microsoft.AspNet.Identity.EntityFramework的依赖。
https://github.com/kriasoft/AspNet-Server-Template- > ./src/App.Server/Data/UserStore.cs
(免责声明:我是该项目模板的作者)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.