I have a Controller where on the Create action I need the user ID.
Here's the controller.
public ActionResult Create(MyCreateViewModel model)
{
if (ModelState.IsValid)
{
var myobject = new MyObject
{
Attrib1 = DateTime.Now.Date,
Attrib2 = model.Etichetta,
UserId = // I need the user ID...
};
// Save the object on database...
return RedirectToAction("Index");
}
return View(model);
}
I'm using the UserProfile
table provided with the SimpleMembership
of MVC 4.
Which is the best practice in MVC 4 to manage the userID
across the application?
Do I have to include a User attribute inside every Entity class?
Should I use a Session[]
variable or what?