【发布时间】:2014-08-19 23:27:22
【问题描述】:
似乎这个问题已经被问过很多次了,在很多方面,似乎没有一个适合我的确切情况。
这是我的 _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()。
我不希望它说“你好电子邮件地址”,而是说“你好 Bob”
我的想法是我只是想在 Identity 类上显示一个新属性(或方法)。显然它必须不止于此。
我添加了 FirstName 属性,并且 它在 AccountController 中可用。
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
它不会暴露在 _LoginPartial 文件中。我希望它暴露在那里!
感谢您的帮助
【问题讨论】:
-
您可以随时调用数据库 其中 Email 是 User.Identity.GetUserName();
标签: c# asp.net asp.net-mvc asp.net-identity