似乎这个问题已经以多种方式被问过很多次了,但似乎都不符合我的具体情况。
这是我的 _LoginPartial.cshtml 文件中的一行:
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
看到 User.Identity.GetUserName() 部分了吗?
我想将其更改为 User.Identity.FirstName 或 User.Identity.GetFirstName()。
我不希望它说“你好电子邮件地址”,而是“你好鲍勃”
我的想法是,我只是想在 Identity 类上显示一个新属性(或方法)。显然它一定不止于此。
我添加了 FirstName 属性并且它是可用的在帐户控制器中。
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
它不会在 _LoginPartial 文件中公开。我想让它暴露在那里!
感谢您的帮助