【问题标题】:UserProfile in MVC5/EF6MVC5/EF6 中的用户配置文件
【发布时间】:2015-05-03 15:04:56
【问题描述】:

SimpleMembership 中曾经有 UserProfile,但在身份 1 和 2 中没有。身份中的正确替代品是什么?

应用用户?

【问题讨论】:

    标签: entity-framework asp.net-mvc-5 entity-framework-6


    【解决方案1】:

    现在存储个人资料信息要容易得多。基本上,只需从 IdentityUser 继承并添加您的自定义数据。这是一篇将身份与简单成员资格进行比较的好文章:http://www.itorian.com/2013/11/customize-users-profile-in-aspnet.html

    【讨论】:

    • 所以我可以使用ApplicationUser 代替UserProfile 并为ApplicationUser 获取Roles 等等?
    • 好吧,您可以简单地注释您的控制器操作 ([Authorize(Roles = "Admin")]),或者您可以使用 Identity UserManager 来检查角色。 HttpContext.Current.GetOwinContext().GetUserManager().IsInRole(UserId, "Admin");
    猜你喜欢
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    • 2015-07-21
    • 1970-01-01
    • 2016-02-05
    • 2015-07-02
    相关资源
    最近更新 更多