I was reading the followed guide in order to know how to share a common view model, but I have a dubt,
Sharing common view model data in asp.net mvc - The objective of the article is to populate authomatically a common view model "LayoutModel" with all their properties using ActionFilterAttributes
public class HomeModel : LayoutModel
{
public string Content { get;set; }
}
The content is populated using an _userService that will return the "CurrentUser", My question is:
Where I have to store my common data? User data etc..? because I don't want to call the database each time that the filter is executed, and I don't know what I have to do on the userservice in that case, I was reading that is not a good idea to store it in session, some ideas will be very agreed!
public void Set<T>(T model) where T : SharedContext, new()
{
var user = _userService.GetCurrent();
model.User = user;
model.UnreadMessageCount = _userMessageService.GetUnreadCount(user.Id);
}