Answer the question
In order to leave comments, you need to log in
What is the difference between ViewBag and @Model?
With @Model it is possible to call only the properties of the model, but with the help of ViewBag / ViewData it is possible to call the data generated by the controller?
Answer the question
In order to leave comments, you need to log in
ViewBag/ViewData - can be transferred and used throughout the page, in all templates, while the model can only be expanded in the template called by the current controller.
Also, ViewBag differs from ViewData in the way data is stored, if "objects" are specified in the first, then in the second, data can be called and stored as in an array. (ViewData["data"], ViewBag.data).
The Model is strongly typed and designed specifically for this View (only available inside the View)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question