title: Run async method in overridden void
body: <p>I'm currently building an ASP.NET MVC application. I'm trying to add items to the ViewBag property for all pages in my site. To achieve this, I've created a base controller that all my site controllers inherit from. </p>
  
  <p>To add to the ViewBag, I've overridden the OnActionExecuting method: <code>protected override void OnActionExecuting(ActionExecutingContext filterContext)</code></p>
  
  <p>I know that the OnActionExecuting methods for MVC5 are not async, which is why I'm running into this issue. I need to be able to call some form of the following code to retrieve the newest items and put them into the ViewBag:</p>
  
  <pre class="lang-cs prettyprint-override"><code>IList&lt;PlaceListItemViewModel&gt; places = await GetLatestPlaces(3);
  ViewBag.FooterLatestPlaces = places;
  </code></pre>
  
  <p>Using the <code>GetLatestPlaces(3).Result</code> just causes a deadlock, so this is not an option.</p>
  
  <p>Could anybody give me an option on how to achieve this. It doesn't have to be overriding the OnActionExecuting method either, if there is another way to add items to the ViewBag for every page (other than calling the code from every single action in every controller), I'm open to using that method. </p>
  
  <p>Unfortunately I can't the GetLatestPlaces method to be non-async, as it's using the MongoDB 2.0 driver, which is async all the way.</p>