如何使用ASP.NET Identity 3.0没有Entity Framework
|
我现在看到的所有例子为ASP.NET Identity 3.0使用Entity Framework来存储用户相关的数据。 有没有使用实体框架和其中ApplicationUser类不是从Microsoft.AspNet.Identity.EntityFramework.IdentityUser派生的任何示例? 在ASP.NET Identity 2.x中,需要实现IUser接口。看来现在没有这样的接口 – 所以我们不知道如何正确定义User类。几乎没有关于这个主题的文档。 第二个问题是在Startup.ConfigureServices中使用AddIdentity调用。它非常依赖于来自Microsoft.AspNet.Identity.EntityFramework命名空间的特定类,并且不清楚如何注册身份服务没有这些类。 解决方法我已经在我的项目中实现它,你必须实现的主要事情是UserStore和RoleStore我的SiteUser和SiteRole类不继承任何东西 主要的是在添加自己的服务之前,让asp.net身份添加自己的服务 services.TryAdd(ServiceDescriptor.Scoped<IUserStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserPasswordStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserEmailStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserLoginStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserRoleStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserClaimStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserPhoneNumberStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserLockoutStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IUserTwoFactorStore<SiteUser>,UserStore<SiteUser>>()); services.TryAdd(ServiceDescriptor.Scoped<IRoleStore<SiteRole>,RoleStore<SiteRole>>()); 一些相同的interfsaces将在这里注册,但它会使用你的,如果他们首先注册 services.AddIdentity<SiteUser,SiteRole>(); (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – ASP.NET MVC 3自定义HTML助手 – 最佳实践/
- asp.net-mvc-3 – 是否可以强制使用DataType作为DataType.M
- asp.net – 在Web.Config的Location Path元素中指定多个目录
- asp.net-mvc – 使用DisplayAttribute和自定义资源提供程序
- asp.net-mvc – 使用AWS .NET SDK进行SNS订阅确认示例
- 如何在asp.net mvc 2中获取Html.EditorForModel()方法的tex
- asp.net-mvc – TDD:在ASP.NET MVC 3中测试DataAnnotation
- asp.net – 如何监视SQL Server中的活动连接池?
- asp.net – Web.Config中的Assemblies节点的目的是什么?
- 如何调试asp.net mvc 4源代码?
- ASP.NET无法访问IIS元数据库
- asp.net-mvc-3 – 在MVC3中使用自定义的IPrincip
- asp.net – FindControl()返回null
- asp.net-mvc – 在部分视图中传递参数 – MVC3 /
- ASP.NET 5针对dnx451 / dnx46性能
- asp.net – 模型项的类型为CookMeIndexViewModel
- asp.net – 运行时从Microsoft.AspNet.WebApi.He
- asp.net – DOM异常:INVALID_CHARACTER_ERR(5)[
- asp.net-mvc – EntityFramework代码在部署到Azu
- asp.net – 使用installshield在安装后运行解决方
