Shaun, here´s an idea:
First, you can create an action filter so that you inject the object that represents your user in the ViewData
collection. You can apply this attribute to your controller or to the actions.
public class AddUserToViewDataAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var email = filterContext.HttpContext.User.Identity.Name;
var user = _userService.GetUser(email);
filterContext.Controller.ViewData["CurrentUser"] = user;
}
}
Some improvements should be made of course, this is just an idea.
Another idea is to create a base controller class (so that your controllers extend it) and in that controller you can have a method (e.g. GetCurrentUser) that does the same as in this filter (i.e. load the user from the DB). You can apply some caching like for example, saving the user object in the HttpContext.Items
collection.
Cheers.