I am actively using ViewBag in my MVC application, is this considered bad practice? I am not sure whether to spend time creating ViewModels (however, I thought it was more suitable for MVVM, not MVC) or to continue to use ViewBag heavily. What are the arguments for and against this? An example controller method returns its model (usually a simple domain object), as well as the following ViewBag calls:
ViewBag.TotalItems = data.Count(); ViewBag.FilteredItems = gridFilters; ViewBag.Action = "Events"; ViewBag.Area = "People"; ViewBag.EntityID = person.EntityID; ViewBag.OrganisationID = ID; ViewBag.Name = string.Format("{0} {1}", person.FirstName, person.LastName); ViewBag.IsEnabled = person.IsEnabled; ViewBag.EntityID = person.EntityID; ViewBag.Favourited = users.IsOnUserFavourites(person.EntityID); ViewBag.Columns = userColumns; ViewBag.Title = "Person : " + string.Format("{0} {1}", person.FirstName, person.LastName) + " - Events";
source share