【发布时间】:2020-03-04 18:30:40
【问题描述】:
我正在 Visual Studio 的 ASP.NET 核心上构建一个预测网站,当然我需要为每个用户提供一个“分数”变量。这就是为什么我通过创建一个以 IdentityUser 作为基类的新类来在内置 IdentityUser 表中添加一个“分数”列。我唯一添加的就是一个名为 Score 的属性。
public class UserIdentity : IdentityUser<Guid>
{
public int Score { get; set; }
}
现在我想在导航栏中显示分数以及当前用户的用户名,但是我收到了错误,即分数与用户名在同一命名空间中不存在。
我的 _Layout 文件中的 HTML 代码(用于导航栏):
@if (signInManager.IsSignedIn(User))
{
<li class="nav-item">
<form method="post" asp-action="logout" asp-controller="account">
<button type="submit" class="nav-link btn btn-link py-0" style="width:auto">Uitloggen @User.Identity.Name <br /> @Convert.ToString(User.Identity.Score) punten</button>
</form>
</li>
}
提前致谢!
【问题讨论】:
标签: visual-studio asp.net-core asp.net-core-identity