0
난, 난 그냥이 가지고있는 IndexViewModel
에서 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">
얻을 이 경우 @Model.user.Xp
에, 그것이 작동하지 않는 특정 사용자로부터 데이터베이스에서 값을 검색 할 수 있도록하려면 :
public class ApplicationUser : IdentityUser
{
[MaxLength(128)]
public string Title { get; set; }
[Range(0, 5000000)]
public int Xp { get; set; }
[Range(0, 100000)]
}
: 나는 모든 속성을 가지고있는
ApplicationUser
클래스에서
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; }
}
Microsoft.AspNet.Identity (노란색의 한 표시)를 통해 ID와 사용자 이름을 가져올 수 없습니다. 나는 다른 모든 속성을 얻을 수 없습니다.
는 나는 내가 볼 수있는 모든 다른 속성의, 아마 보여 아무 문제가 없다, User.Identity.GetUserName() 내 질문에 조금 불분명했다. – Godnatt
모델을 컨트롤러에 적절한 데이터로 채우고 있습니까? 보기에서 모델을 채울 수 없습니다. – shad0wec
나는 당신의 답 = 위의 덕택으로 해결했다고 생각한다.) Nice – Godnatt