Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject'
asp.net-mvc, c#, dynamicobject, viewbag
Solution
Have you tried
ViewBag.SuccessBody = TempData["successBody"];
Problem
When I try to assign a value to the ViewBag I get the following error: Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject' My code is as follows: ``` public ActionResult Success() { ViewBag["SuccessBody"] = TempData["successBody"]; return View(); } ``` 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.