首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >脚手架用户

脚手架用户
EN

Stack Overflow用户
提问于 2016-05-15 17:12:15
回答 1查看 53关注 0票数 0

我在Asp.net mvc上有点新手,在我的项目中,我将有一个用户注册,一个编辑用户配置文件和查看用户配置文件(创建,编辑,详细信息)的可能性,有没有一种方法,我可以添加新的属性到用户表,以便我可以脚手架用户?在那一刻,我只是这样做的:

代码语言:javascript
复制
 public class ApplicationUser : IdentityUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }

    [Required]
    public string Nome { get; set; }
    public string Telemóvel { get; set; }
    public int Idade { get; set; }
    public string Sobre { get; set; }


}

我需要扩展用户身份才能做我想做的事吗?我该怎么做呢?

EN

回答 1

Stack Overflow用户

发布于 2016-05-15 17:39:18

搭建通常是通过ViewModels完成的,而不是在模型类上。要实现此目的,请使您的身份用户具有(如有必要,可自定义属性),添加迁移并创建一个单独的ViewModel类,该类具有注册新用户所需的自定义属性,并在post操作中将映射到身份用户。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37236465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档