title: ViewBag vs Session variable
body: <p>I am being asked to switch out my use of a Session variable for <code>ViewBag.Property</code>. </p>
  
  <blockquote>
    <p>In BaseAdminInterfaceController.cs - please do not use <code>Session[&lt;string&gt;]</code> and instead use <code>ViewBag.Property</code>. The reasoning for this is that the OnActionExecuting method is executed multiple times per request and therefore storing to Session (which saves beyond the request lifecycle) is unnecessary, ViewBag is simple, new, and works well in this case.</p>
  </blockquote>
  
  <p>Here is the code in a BaseController:</p>
  
  <pre><code>protected override void OnActionExecuting(ActionExecutingContext filterContext)
  {
      if (Session["House"] == null) Session["House"] = Enums.Houses.Black;
  }
  </code></pre>
  
  <p>My issue here is that the life of <code>ViewBag.Property</code> only exists during the current request.  It cannot be used to pass a variable from action to action, or view back to the controller. Is ViewBag better?</p>