I'm giving MVC another shot, and I feel like I'm learning freakin' HTML all over again.
So, stupid question: At the top of my master page, I've got a partial view (or similar - I'm using the string template view engine and so far I love it) which either displays a small login form (similar to what NewEgg has), or a message like
You are signed in as (Name). [Profile] | [Sign out]
Unfortunately, I'm having a brain cramp and can't determine the best way to get that data (username, id) into the ViewData collection without explicitly specifying it in every controller method, like
public ActionResult Index()
{
ViewData["IsAuthenticated"] = Session["IsAuthenticated"];
ViewData["user.firstname"] = User.FirstName;
return View("login");
}
That's pretty annoying to have to replicate all over the place. My next option would be to create a method called PopulateCommonViewData() and just call that from every action method, but that also seems lousy.
Am I missing something here?