![](/img/trans.png)
[英]How can I connect IdentityUser with Recipe in ASP.NET MVC
[英]How to get user profile data from ASP.NET MVC custom IdentityUser Model?
在這篇博客的幫助下,我在ApplicationUser類中添加了一個自定義配置文件屬性OfficeKey (在IdentityModels.cs文件中):
public class ApplicationUser : IdentityUser
{
public int OfficeKey { get; set; }
//remaining code here
}
我可以得到這樣的用戶名:
User.Identity.Name
如何獲取自定義用戶數據OfficeKey ?
我試過這些:
如何從ASP.NET MVC默認Mempership模型獲取用戶電子郵件地址?
注意:它是一個帶有MySQL成員資格提供程序的ASP.NET MVC 5 Web應用程序。
如果使用ApplicationUser
配置UserManager
,它將返回具有以下信息的用戶:
// Create manager
var manager = new UserManager<ApplicationUser>(
new UserStore<ApplicationUser>(
new ApplicationDbContext()))
// Find user
var user = manager.FindById(User.Identity.GetUserId());
OfficeKey
將在用戶中可用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.