title: Set ViewBag from ActionFilterAttribute
body: <p>The site I am creating custom colors that can be set by the user (only on certain pages). I want to grab that data within an ActionFilterAttribute and set it in the ViewBag so I can then get the data in my _Layout.cshtml.</p>
  
  <p>Here is my ActionFilterAttribute...</p>
  
  <pre><code>public class PopulateColorOptionsAttribute : ActionFilterAttribute
  {
      private readonly OptionsDataHelper optionsDataHelper;
  
      public PopulateOptionsAttribute(OptionsDataHelper optionsDataHelper)
      {
          this.optionsDataHelper = optionsDataHelper;
      }
  
      public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
      {
          await base.OnActionExecutionAsync(context, next);
  
          // Get the cemetery data and set it on the view bag.
          var personId = Convert.ToInt32(context.RouteData.Values["personId"]);
          context.Controller.ViewBag.OptionsData = await optionsDataHelper.GetValueAsync(personId, CancellationToken.None);
      }
  }
  </code></pre>
  
  <p>Unfortunately, I receive an error on ViewBag that states:</p>
  
  <blockquote>
    <p>'object' does not contain a definition for 'ViewBag' and no extension method 'ViewBag' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) [dnx451]</p>
  </blockquote>
  
  <p>I'm pretty sure I'm not understanding something correctly about Filters and I would appreciate guidance on how to achieve what I am looking to do.</p>