How to include user in model

BABIIGURL

New Member
I'd like to have a user in my model. By user I mean something that holds username. Email and the rest of the stuff would also be nice.I tried like that:Model:\[code\]public class MyModel{ public virtual MembershipUser Finder { get; set; } ...}\[/code\]Controller:\[code\][HttpPost] public ActionResult Create(MyModel mymodel) { if (ModelState.IsValid) { //mymodel.FinderId = Membership.GetUser(User.Identity.Name).ProviderUserKey; mymodel.Finder = Membership.GetUser(User.Identity.Name); _repo.Save(mymodel); return RedirectToAction("Index"); } return View(mymodel); }\[/code\]And than in a view:\[code\]@Html.DisplayFor(modelItem => item.Finder.UserName)\[/code\]While in the controller the poperty UserName was set to "admin" in the view it was null.On the other hand email was set in both controller and view.What am I doing wrong?
 
Back
Top