This is probably a silly question, but I am trying to stuff an anonymous object in ViewBag
like so:
ViewBag.Stuff = new { Name = "Test", Email = "[email protected]" };
and access it from a View like so:
@ViewBag.Stuff.Name
I understand ViewBag is dynamic and that "Stuff" is an anonymous object... but when I look with the debugger from the View line above, I can see all the properties with the proper values. Why does the model binder have such a hard time with this?
Is there a good way to accomplish this without creating a model class? I want to continue using new {}