小编Fri*_*rip的帖子

如果我继承自IdentityUser,如何获取当前用户ID?

我在 IdentityUser 中添加一些字段,例如

public class CustomUser: IdentityUser
    {
        public string field1 {get;set;}
        public string field2 {get;set;}
    }
Run Code Online (Sandbox Code Playgroud)

迁移后,在 Sql Management studio 上我拥有所有数据,我添加了.OnModelCreating

但是,我如何从当前授权的 CustomUser 中获取任何字段(如 ID)

我尝试使用

using Microsoft.AspNet.Identity;

CustomUser.Identity.GetUserId()
Run Code Online (Sandbox Code Playgroud)

但这不起作用。

感谢帮助!

asp.net asp.net-identity asp.net-core asp.net-core-identity

7
推荐指数
1
解决办法
1万
查看次数