在
this blog的帮助下,我向ApplicationUser类添加了一个自定义配置文件属性OfficeKey(在IdentityModels.cs文件中):
public class ApplicationUser : IdentityUser { public int OfficeKey { get; set; } //remaining code here }
我可以得到这样的用户名:
User.Identity.Name
How do I get custom user data OfficeKey?
我试过这些:
How to get Identity User Data from Asp.net mvc Model
How to get user email address from ASP.NET MVC Default Mempership Model?
注意:它是一个带有MysqL成员资格提供程序的ASP.NET MVC 5 Web应用程序.