I have seen many posts about when to use ViewBag/ViewData vs ViewModel but i have not been able to find an explanation of the lifecycle of the ViewBag.
For example,
ViewBag and ViewData are used for the same purpose. They are used to pass data from controllers to the View. When we assign any data or object to them they are accessible in the View.
ViewData: ViewData is a dictionary of objects and they are
accessible by string as key.ViewBag: Uses the dynamic feature. It allows an object to add
dynamic properties to it.