Reputation: 1265
Is there a built-in way of associating persistent model data with an authenticated user in MVC4, or are you supposed to provide your own implementation?
The MSDN tutorials I've read don't suggest how to do it, but I've seen a WebSecurity.CurrentUserId
property I could store. For example, a model for a site that allows the user to upload photos:
public class Photo
{
public int Id { get; set; }
public int UserID { get; set; } // Controller sets WebSecurity.CurrentUserId?
public DateTime Created { get; set; }
...
}
Or is there an "MVC way"?
Upvotes: 3
Views: 288
Reputation: 2750
can you not use something like this:
public class Photo
{
public int Id { get; set; }
public int UserID { get; set; }
public DateTime Created { get; set; }
public UserProfile user {get;set;}
...
}
public class UserProfile
{
public int UserID { get; set; }
}
Upvotes: 1