【发布时间】:2016-08-24 08:10:42
【问题描述】:
我希望能够从数据库中检索值
特定用户,在这种情况下@Model.user.Xp,它不起作用,我
只得到 0。
@model TheQuizR.Models.IndexViewModel
@using Microsoft.AspNet.Identity
<div class="row">
<div class="col-sm-6 col-md-6">
<ul class="list-group">
<div class="blue">
@User.Identity.GetUserName()<br />
</div>
<li class="list-group-item">
Title
<span class="badge">@Model.user.Xp</span>
</li>
<li class="list-group-item">
在IndexViewModel我有这个:
public class IndexViewModel
{
public ApplicationUser user = new ApplicationUser();
public bool HasPassword { get; set; }
public IList<UserLoginInfo> Logins { get; set; }
public string PhoneNumber { get; set; }
public bool TwoFactor { get; set; }
public bool BrowserRemembered { get; set; }
}
在ApplicationUser 类中,我拥有所有属性:
public class ApplicationUser : IdentityUser
{
[MaxLength(128)]
public string Title { get; set; }
[Range(0, 5000000)]
public int Xp { get; set; }
[Range(0, 100000)]
}
我无法通过 Microsoft.AspNet.Identity(黄色的一个标记)获取 id 和用户名。我无法获取所有其他属性。
【问题讨论】:
标签: c# .net asp.net-mvc ef-code-first asp.net-identity