近来一直翻阅国内网站,发现扩展字段的时候仅仅做到了可以注册时候添加,并修改数据库,但是后续的操作就没有了,那么列如我添加了昵称字段,怎么显示呢?不知是不是因为我刚入门的原因,一直没有找不到方法,最后再国外论坛找到了方法。核心为下面4句话,简单记录,晚上后续展开修改
1 var currentUserID = User.Identity.GetUserId(); 2 var manage = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); 3 var currentUser = manage.FindById(User.Identity.GetUserId()); 4 ViewBag.Birthday=currentUser.Birthday;
指路地址 https://blogs.msdn.microsoft.com/webdev/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates/
网页中有语句是错误的,但是作者并没有回复,但表示开源了自己的实例 https://github.com/rustd/AspnetIdentitySample