0
我希望能够从从 特定用户,在这种情况下@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和用户名。我无法获得所有其他属性。
我可能是在我的问题有点不清楚,User.Identity.GetUserName()是没有问题的显现,这一切都让我无法看到的其他属性。 – Godnatt
您是否在控制器中填充适当数据的模型?您无法填充模型。 – shad0wec
我想我解决了它,这要归功于上面的答案=)好的 – Godnatt