Quick Introduction of ViewBag
ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0. ViewData requires typecasting for complex datatypes and checks for null values to avoid errors.
Basically, ViewBag and ViewData are similar in use when we use them to pass data from Controller to View.
Controller Class
Accessing ViewBag in Cshtml file
Output