So I added the following to my _Layout page:
@Html.Action("ActiveMails", "Home")
Which calls the following actions:
public void ActiveMails()
{
var ooo = from s in db.Message
where (s.SentTo.ToLower() == HttpContext.User.Identity.Name.ToLower())
&& s.Read != "1"
&& s.Active == "1"
select s;
ViewBag.UnreadMessages = ooo.Count();
}
The problem is that when the page loads it doesn't retain the ViewBag info. Is there any way I can have this code run on every request, but retain the ViewBag information?