title: Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject'
body: <p>When I try to assign a value to the ViewBag I get the following error:</p>
  
  <blockquote>
    <p>Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject'</p>
  </blockquote>
  
  <p>My code is as follows: </p>
  
  <pre><code>public ActionResult Success()
  {
     ViewBag["SuccessBody"] = TempData["successBody"];
     return View();
  }
  </code></pre>
  
  <p>PS: Why I do this you may ask? Because I am redirecting to the Success action and I needed something that persists across redirects. Then, I am assigning the value to ViewBag in order to pass the Value to a 'shared' view. </p>